Commit Graph
195 Commits
Author SHA1 Message Date
4ad88a327e feat: add GDPR cookie consent banner (#1216)
* feat: add GDPR cookie consent banner

Add a GDPR-compliant cookie consent banner that gates analytics (Google
Analytics) and functional cookies (comments) until user consent is given.

Features:
- Theme-consistent styling using CSS variables (light/dark mode)
- Settings panel with category toggles (necessary, analytics, functional)
- Consent stored in cookie for 365 days
- Google Analytics only loads after analytics consent
- Comments only load after functional consent
- Translations for all 32 supported languages
- Accessible with proper ARIA attributes and focus management

Configuration in hugo.yaml:
  params:
    cookies:
      enabled: true
      categories:
        analytics: true
        functional: true

When cookies.enabled is false, scripts load normally without consent gating.

Closes #412

* refactor: move consent-gated GA to cookies/analytics.html

Move Google Analytics consent logic to avoid shadowing Hugo's internal
`_internal/google_analytics.html` template.

Changes:
- Rename google_analytics.html → cookies/analytics.html
- Update head.html to conditionally load:
  - cookies.enabled=true: cookies/analytics.html (consent-gated)
  - cookies.enabled=false: Hugo's _internal/google_analytics.html
- Align cookies/analytics.html with Hugo's internal template:
  - Support Privacy.GoogleAnalytics.Disable setting
  - Support Privacy.GoogleAnalytics.RespectDoNotTrack setting
  - Add UA- prefix deprecation warning

Note: Custom JS is required for consent-gated GA because Hugo templates
render at build time, but consent happens at runtime. We cannot call
Hugo's internal template after the user grants consent - we must
dynamically inject the GA script via JavaScript.

* style: indent cookies/analytics.html

* refactor: don't use default, put default configurations in params.toml

* fix: don't use `description` as translation key because it's reserved and will throw error

* fix: remove footer/components/custom-font.html call

* fix: banner showSettings key

* style: indent comments/include

* Add missing article.alert translation back

* style: format i18n toml files

* style: indent head/head.html

* style adjustment

* style: add missing -

* style: format demo/config/params.toml

* style: remove redundant comments from cookies.scss

* style: update box-shadow for cookie banner content

---------

Co-authored-by: delize <4028612+delize@users.noreply.github.com>
Co-authored-by: Jimmy Cai <jimmy@cai.im>
2026-02-19 17:21:25 +01:00
470295171e feat: add markdown alerts support (#1221)
* Markdown alerts

* refactor(alert): move alert color to variable.scss and simplify the style

* style: fix indent in render-blockquote

* feat(alert): add customizable alert icons for different alert types

* doc: add example usage of markdown alert

---------

Co-authored-by: Jimmy Cai <jimmy@cai.im>
2026-02-18 19:43:34 +01:00
JimmyandGitHub b4e44fda57 fix: enhance image caption handling by using title attribute if available (#1265)
* fix: enhance image caption handling by using title attribute if available

* feat: support markdown syntax inside image caption
2026-02-17 18:38:06 +01:00
JimmyandGitHub 3806cc9230 fix: set width of left and right sidebars to 100% (#1264)
This prevents the width from changing when the left or right sidebar does not have enough content to stretch to 100%.
2026-02-17 18:10:33 +01:00
bc1b55e60a fix: improve Mermaid diagram implementation (#1214)
* fix: improve Mermaid diagram implementation (#1213)

This commit addresses multiple issues with Mermaid diagram rendering
and adds significant improvements to the user experience.

- Fix `<br/>` tags rendering as literal text instead of line breaks
- Fix flash of raw mermaid code before diagram renders
- Fix Gantt chart rendering issues in dark mode
- Fix diagrams briefly showing during theme switch re-render
- Fix expand modal showing diagram left-aligned before centering

- Add fullscreen expand modal with pan/zoom functionality
- Add toolbar with zoom controls (zoom in/out, reset, fit to screen)
- Add keyboard support (Escape to close modal)
- Add per-diagram transparent background via `%%transparent%%` directive
- Add comprehensive configuration options:
  - `look`: classic or handDrawn (sketch style)
  - `lightTheme`/`darkTheme`: theme selection per mode
  - `lightThemeVariables`/`darkThemeVariables`: custom theme colors
  - `securityLevel`, `htmlLabels`, `maxTextSize`, `maxEdges`
  - `fontSize`, `fontFamily`, `curve`, `logLevel`

- Switch from ESM to UMD bundle for faster initial load (~1s vs 2s+)
- Lazy-load panzoom library only when expand modal is opened
- Pre-render alternate theme during idle time for instant theme switching
- Cache rendered diagrams to avoid re-rendering on theme toggle

- Move all inline CSS to article.scss using SCSS nesting
- Extract helper functions for better maintainability
- Use data attributes and event delegation for cleaner handlers
- Reduce mermaid.html from 411 to 177 lines (57% reduction)

- Add comprehensive mermaid-diagrams example post with all diagram types
- Document all configuration options in hugo.yaml

* refactor: extract mermaid inline JS to TypeScript module

Move ~155 lines of inline JavaScript from mermaid.html partial into
assets/ts/mermaid.ts. The partial shrinks from 179 to 36 lines and now
only contains modal HTML markup and Hugo Pipes build/import logic.

- Deduplicate initWithTheme() and renderOffscreen() helpers
- Enable minification via Hugo Pipes js.Build in production
- Remove user-configurable mermaid version from params.toml

---------

Co-authored-by: delize <4028612+delize@users.noreply.github.com>
2026-02-17 17:55:03 +01:00
JimmyandGitHub 0f33b3efb7 feat: add collapsible table of contents for smaller screens (#1245)
* refactor: create partial/article/components/toc

* feat: add collapsible table of contents for smaller screens
2026-01-26 22:28:27 +01:00
JimmyandGitHub 258a71e21a fix: mobile menu glitch on collapsing (#1243) 2026-01-26 14:13:16 +01:00
JimmyandGitHub a069e975aa style: remove extra margin in article description (#1242) 2026-01-26 13:52:10 +01:00
Jimmy Cai b1c5986b2f style: fix <select> padding in iOS Safari 2026-01-26 00:13:36 +01:00
JimmyandGitHub fe7a0566df style: remove vendor style of <select> in i18n switch (#1238)
This removes the annoying left padding
2026-01-26 00:03:27 +01:00
JimmyandGitHub ae0de75992 refactor: remove Vibrant.js (#1236)
* refactor: migrate image color extraction from client-side JavaScript to server-side Hugo.

* fix: check if image exists before accessing .Resource
2026-01-25 23:42:28 +01:00
JimmyandGitHub b1ddad1d22 feat: upgrade to PhotoSwipe v5 (#1233)
* refactor: migrate external resource definitions from YAML to TOML format

* feat: upgrade to PhotoSwipe v5
2026-01-25 23:13:34 +01:00
JimmyandGitHub 406fcef7cd refactor: use TOML for configuration file (#1228)
* refactor: remove jsconfig.json

* chore: remove devcontainer config

* refactor: migrate Hugo configuration from `hugo.yaml` to dedicated `module.toml` and `params.toml` files, and update minimum Hugo version.

* refactor: migrate demo site configuration from `hugo.yaml` to `config/_default/*.toml`

* feat: enable local sidebar avatar for demo site and relocate its image to demo assets.

* feat: migrate demo site to Hugo Modules for theme management.

* fix: wrong config folder name
2026-01-25 19:51:10 +01:00
JimmyandGitHub 12daa8c9fc feat: dynamically generate background color for category links (#1225)
* chore: add +x to run.sh

* feat: dynamically generate background color for category links using hash

* feat: allow category styles to be overridden by term parameters

* refactor: remove default tag background and color variables
2026-01-25 17:35:40 +01:00
JimmyandGitHub 475d01b046 fix: adjust padding and width for article list tiles in subsection list (#1211) 2025-12-22 16:51:39 +01:00
5a5876e3ea refactor(scss): remove--zh-font-family (#1183)
* fix(scss): limit `--zh-font-family` to only simplified Chinese

* feat(sampleSite): add test page for Japanese & Traditional Chinese

* Remove `--zh-font-family` variable

---------

Co-authored-by: Jimmy <jimmy@cai.im>
2025-12-22 16:28:58 +01:00
47db505228 feat: pagination improvements to maximize space utilization (#1165)
* Minor improvements to pagination functions

* Update pagination styles with enhanced UI/UX design

- Implemented full-width layout with flexible page numbers
- Added fixed-width arrow buttons for consistent navigation
- Enhanced hover and active states for better user interaction
- Improved responsive design with proper flex layout
- Added comprehensive styling for disabled and ellipsis states

* Simplify pagination logic and use SVG files to avoid repeated definition

* Remove change to jsconfig.json

* Remove comments and classes

---------

Co-authored-by: delize <4028612+delize@users.noreply.github.com>
Co-authored-by: Jimmy <jimmy@cai.im>
2025-12-22 00:21:02 +01:00
Jerry KimandGitHub 145cda7d45 feat: use ResizeObserver to detect changes in the size of .article-content (#1105)
* Use ResizeObserver to detect changes in the size of .article-content

This code is for handling changes in position caused by content rendered as part of post-processing, such as Mermaid diagrams

* Add debounced to resizeHandler
2025-11-01 21:59:30 +01:00
Gleb A.andGitHub 8f7eeb7de6 fix: Uncaught TypeError: link is null in buildIdToNavigationElementMap (#1133)
fix: Uncaught TypeError: link is null in buildIdToNavigationElementMap (#1132)
2025-11-01 21:57:02 +01:00
JimmyandGitHub 2f47d14a8a fix: add missing object-fit: cover to section-image (#1196) 2025-11-01 20:43:19 +01:00
KonnyakuandGitHub 2d1d6727f5 feat(scss): Enhance text rendering with autospace properties (#1188)
* Enhance text rendering with autospace properties

Added text autospace properties for better text rendering for CJK characters.

* Update text-autospace and text-spacing properties
2025-11-01 19:33:23 +01:00
Jimmy CaiandGitHub 37f1541c20 feat: search box in 404 page (#1081) 2024-10-20 00:26:59 +02:00
PukNgae CryolitiaandGitHub 245b0f2810 fix(colorScheme): systemPreferScheme not initialized on start up (#1061) 2024-10-06 19:32:13 +02:00
Jimmy CaiandGitHub fcd56dd21c fix: article category overflow (#1055)
closes https://github.com/CaiJimmy/hugo-theme-stack/issues/1045
2024-09-07 13:25:26 +02:00
Jimmy CaiandGitHub f3783856ad feat: add article.headingAnchor parameter and use CSS pseudo-element to display # symbol of heading anchor (#1016)
* feat: add `article.headingAnchor` parameter

* feat: use CSS pseudo-element to display `#` symbol of heading anchor

This prevents RSS feed readers and screen readers from seeing an extra `#`.

* Deactivate `article.headingAnchor` by default
2024-05-02 23:27:17 +02:00
Jimmy CaiandGitHub 130e2f6607 feat: display header anchor on hover (#999) 2024-03-30 23:22:18 +01:00
Jimmy CaiandGitHub 797949b37f fix: rename .social-menu to .menu-social to avoid being blocked by ad blockers (#993)
closes https://github.com/CaiJimmy/hugo-theme-stack/issues/924
2024-03-27 16:24:03 +01:00
Jiahao LiandGitHub 6c7d42d45a fix(sidebar): menu-bottom-section not showing in mobile (#966)
* fix(sidebar): Bottom section not showing in mobile

* fix(sidebar): Align bottom section to bottom

* fix(sidebar): Gap missing in bottom section

* refactor(sidebar): Simplify styles

* refactor(sidebar): Remove useless padding-left

* refactor(sidebar): Remove useless margin-top

* refactor(sidebar): Combine duplicate flex-direction

* refactor(sidebar): Remove redundant width
2024-03-10 22:56:30 +01:00
d84d0a8522 fix(menu): consistent svg coloring in menu (#837)
* Consistent svg coloring in menu

* fix: use `currentColor` to avoid breaking style of active element

---------

Co-authored-by: Jimmy Cai <hi@jimmycai.com>
2023-09-03 16:15:51 +02:00
Jacob ZhongandGitHub be4fd55095 feat(article): font enhancement (#767)
Change font settings
2023-09-03 15:32:44 +02:00
SimbaFsandGitHub d3682b3567 fix(article): margin collapsing in code block (firefox) (#833)
fix margin collasping in codeblock
2023-09-03 13:03:17 +02:00
Jimmy CaiandGitHub 41c3033d1a feat(article): add style to <kbd> tag (#862)
* fix: set `unsafe` to true for exampleSite

To display `<kbd>` tag correctly

* feat(article): add style to `kbd` tag

* feat: improve `<kbd>` style
2023-08-15 13:15:32 +02:00
Jimmy CaiandGitHub 4e2e90da4c fix: page translation links overflow (#861)
closes https://github.com/CaiJimmy/hugo-theme-stack/issues/788
2023-08-15 12:46:29 +02:00
Jimmy CaiandGitHub eefa686661 fix: add word-break: break-word; to <a> and <code> (#860)
closes https://github.com/CaiJimmy/hugo-theme-stack/issues/746
2023-08-15 11:47:48 +02:00
Jimmy CaiandGitHub f7e442cabb fix(search): reset lastSearch variable if keywords are empty (#858)
closes https://github.com/CaiJimmy/hugo-theme-stack/issues/832
2023-08-12 13:03:45 +02:00
26d2859f70 fix: very poor color contrast for default text (#845)
Resolves #754

Co-authored-by: Nick Kocharhook <nick@kocharhook.com>
2023-08-12 11:57:02 +02:00
Jacob ZhongandGitHub 1bd4dcd415 fix(sidebar): add padding-bottom to the right sidebar (#765)
Add bottom padding to the right sidebar
2023-07-12 09:12:58 +08:00
rock GandGitHub 3ff06fe033 fix: anchor link need decode (#719) 2022-12-05 21:21:37 +01:00
Jimmy CaiandGitHub b03390d237 Revert "Merge branch 'canary' into master" (#712)
Revert "Merge branch 'canary' into master (#711)"

This reverts commit 8a597a5c9c.
2022-10-29 17:14:19 +02:00
Jimmy CaiandGitHub 8a597a5c9c Merge branch 'canary' into master (#711)
* refactor(i18n): simplify the structure of the translation file

* chore: prepare repository for v4.0.0-alpha

* chore: modify go.mod to v4

* refactor: migrate theme configuration to TOML

* fix: exampleSite not using correct theme

* feat: add favicon from assets folder

* refactor: drop linear grandient background feature

remove node-vibrant from dependencies

* feat: use Hugo's code block render hook to implement code copy button

Now it can have i18n support

* refactor: delete color.ts

* refactor: delete Emoji support post from example site

* refactor: drop support for `hidden` field in front matter

* feat: upgrade to PhotoSwipe v5

* chore: bump the required hugo version to 0.100.0

* refactor: remove PhotoSwipe from external.yaml

* fix: extra margin in search result

* fix: incorrect markdown heading level in example site

* refactor: remove some usages of `default` in template

No longer needed thanks to Hugo's configuration merge

* fix: one line codeblock style in firefox

closes https://github.com/CaiJimmy/hugo-theme-stack/issues/564

* feat: add style to new codeblock

* feat: i18n support for codeblock copy text

* fix(menu): jitter when closing menu

It's caused by flexbox gap property, which can't animate

* fix(search): long text overflows under the Search icon

closes https://github.com/CaiJimmy/hugo-theme-stack/issues/515
2022-10-29 17:02:24 +02:00
MartinAramayoandGitHub 30e033c660 feat(article): make long KaTeX equations scrollable in the x-axis (#706)
* Make long KaTeX equations scrollable in the x-axis

Suggested from: https://katex.org/docs/issues.html, I have tested it adding a long equation and activating a phone user agent.

* refactor: move KaTeX style to article.scss
2022-10-29 14:38:44 +02:00
ae497c4789 refactor(grid): avoid sidebar layout shift when main content loads slowly (#677)
Co-authored-by: Luguoba <80254980+luguoba@users.noreply.github.com>
2022-10-21 13:06:06 +02:00
Allen GuanandGitHub e1a85aa5cd refactor(highlight): extract common parts of styles and keep line number visible when scrolling (#681)
* merge highlight.scss

* show line number when scroll
2022-10-02 11:38:42 +02:00
Jimmy Cai 655b5102c4 fix(article): footnote reference does not work
closes https://github.com/CaiJimmy/hugo-theme-stack/issues/632
2022-07-28 16:48:37 +00:00
rmdhnrezaandGitHub 3d09c23284 feat(article): GitLab Snippets Shortcode (#627) 2022-06-11 11:04:20 +02:00
lonzziandGitHub 7142de24cc fix(article): TOC link not working when the heading starts with digits (#603) 2022-06-11 00:39:16 +02:00
cubercslandGitHub 9aa6b4925b fix(style): toc counter is incorrect when there are <a> in heading (#601)
closes https://github.com/CaiJimmy/hugo-theme-stack/issues/495, https://github.com/CaiJimmy/hugo-theme-stack/issues/589
2022-06-11 00:34:19 +02:00
Simon GuestandGitHub 772b9e3ba8 fix(article): regression in article copyright link box-shadow (#611)
Somewhere between hugo 0.88.1 and 0.98.0, box-shadow got applied
to the article copyright, which is an ugly regression.
2022-06-08 18:21:28 +02:00
955bb8dd7f feat(shortcodes): add quote shortcode, and example (#414)
* Add quote shortcode, and example

* Use trim to improve whitespace

* Allow for quote with neither author nor source

* Format code and move quote.scss to article.scss

This style is only used on the article page, so it makes more sense to have it there.

Co-authored-by: Jimmy Cai <github@jimmycai.com>
2022-06-08 17:59:23 +02:00
Spence ChurchillandGitHub 5e350b92e8 refactor: rename "Related contents" to "Related content" (#567) 2022-06-05 17:20:08 +02:00