103 Commits
Author SHA1 Message Date
JimmyandGitHub 08a8b5d767 feat: codeblock improvements (#1328)
* fix: do not show codeblock copy button if clipboard api is not available

related: https://github.com/CaiJimmy/hugo-theme-stack/issues/1309

* fix: remove duplicated codeblock script in main.ts

* feat: add i18n support to codeblock copy button

* feat: add translation strings for codeblock copy button
2026-04-26 13:40:46 +02:00
37f6a77a1a feat: Add jump-to-page dialog and improve pagination logic and styling (#1303)
* feat: add jump-to-page dialog on pagination ellipsis

- Replace pagination windowing algorithm with a tighter 5-item window
  (curr-1 / curr / curr+1, clamped at edges) and hide-on-mobile for
  pages more than 1 step away from the current page
- Ellipsis spans now carry the pagination-jump-trigger class and open
  a native <dialog> on click instead of being static decorations
- Add <dialog id="pagination-jump-dialog"> with number input, Go button,
  and Enter-key hint; data-total / data-first-url / data-format-url
  attributes on <nav> give the JS all it needs to build the target URL
- Add assets/ts/pagination.ts: setupPaginationJump() with Fisher-Yates
  backdrop-click and ESC handling, animated open/close via .closing class
- Wire setupPaginationJump() into Stack.init() in main.ts
- Extend pagination.scss with .hide-on-mobile, .pagination-jump-trigger
  hover style, and the full #pagination-jump-dialog styling + keyframe
  scale-up/scale-down animations
- Add [pagination] i18n keys (jumpToPage / jump / pressEnter) to
  en / zh / zh-hant-tw / zh-hant-hk / ja

* style: align pagination code with upstream conventions

- pagination.html: collapse multi-line span/class/aria attrs to single
  lines; use HTML5 void element syntax; fix hint div indentation
- pagination.scss: 2-space indent → 4-space indent
- pagination.ts: tab indent → 4-space indent; export const arrow fn →
  export function declaration

* chore: update layouts/_partials/pagination.html

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* chore: add aria-labelledby attrributes for better accesibility

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: use { once: true } for the listener and guard against re-entry when .closing is already set.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* style: replace hardcoded values with design tokens and improve dialog UX

- Replace all hardcoded px spacing in .page-link with --spacing-* tokens
- Use @include card-style in #pagination-jump-dialog; override with --shadow-l2
- Replace padding: 24px with var(--card-padding) for responsive dialog padding
- Align header title/subtitle to space-between for cleaner layout
- Replace hardcoded gaps/padding in form with spacing tokens
- Fix input/button border-radius from 8px to 6px (better proportion for 44px height)
- Fix focus ring: use color-mix(accent-color 20%) so it's visible in dark mode
- Add :focus-visible + outline:none to fully suppress native browser outline
- Remove translateY from button hover for more restrained interaction
- Scope transition to specific properties (border-color, box-shadow, background-color)

* chore: add pagination test articles for easier debugging

* style: enhance backdrop animations for pagination jump dialog

* style: replace pagination ellipsis spans with buttons for improved accessibility

* fix: check if browser supports dialog API before continue with pagination jump setup

* fix: retain focus on last active element when closing pagination jump dialog

* fix: style for page-link button (pagination-jump)

* style: adjust width of pagination jump dialog, add container padding

* style: simplify

* refactor: simplify pagination link logic

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Jimmy Cai <jimmy@cai.im>
2026-04-26 12:41:31 +02:00
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
JimmyandGitHub 3a0d70ebbd feat(i18n): add i18n support for Markdown alert (#1269)
* docs: add blockquote with custom alert title

* feat: add alert types to i18n and update blockquote rendering

* fix: wrong translation key

* feat: add alert title translation for all supported languages

Done by AI
2026-02-18 20:07:59 +01:00
Jimmy Cai ff2e308445 fix: correct pluralization of 'minute' in English reading time. 2026-01-27 14:04:16 +01:00
JimmyandGitHub 017fbf982d chore: update Traditional Chinese localization files (#1251)
closes https://github.com/CaiJimmy/hugo-theme-stack/issues/1222
2026-01-27 12:49:44 +01:00
JimmyandGitHub c872a77edb refactor: migrate i18n files from YAML to TOML format and simplify structure (#1230)
* refactor: migrate i18n files from YAML to TOML format and simplify structure

* refactor: make translation file adjust to gohugoio/locales language code so date translation can work properly

* refactor: use hyphens instead of underscores for i18n, because that's how Hugo pick the translation file

* docs: update comments for i18n language availability and CJK language detection in hugo.toml.
2026-01-25 21:01:32 +01:00
AiratTopandGitHub dc94a29617 fix(i18n): category widget title in ru.yaml (#1199)
Fix category widget title in ru.yaml
2025-12-21 20:59:59 +01:00
Gleb A.andGitHub d507f2ef7c fix(i18n): minor translation changes for Italian (#1127) 2025-11-01 21:57:12 +01:00
stanolandGitHub 0b22c0a293 fix(i18n): missing translation for title of categories widget in uk.yaml (#1162) 2025-11-01 21:36:29 +01:00
-Zonbi@TR~$andGitHub 50a42f28c0 feat(i18n/tr): add missing translations for tr language (#1160) 2025-11-01 21:28:26 +01:00
HamzaandGitHub 087989e427 chore(i18n): fix a tiny typo in the footer (#1099) 2024-12-22 14:53:10 +01:00
onavas33andGitHub 2a18a92901 fix(i18n): missing translation for title of categories widget in fr.yaml (#1059) 2024-10-06 19:33:20 +02:00
Vladimir VitkovandGitHub 23ff70d41a feat(i18n): add Bulgarian translations (#1007) 2024-09-07 17:56:17 +02:00
ensag-devandGitHub 41a3e5ee13 feat(i18n): add Occitan translations (#1034) 2024-09-07 17:52:40 +02:00
Jimmy CaiandGitHub f8466d94d2 fix(i18n): wrap footer.builtWith with double quotes in Japanese translation (#991) 2024-03-27 16:01:43 +01:00
Shun SakaiandGitHub 43e074364c feat(i18n): update translations for ja (#984)
* feat(i18n): update translations for `ja`

* Apply review suggestions
2024-03-27 11:21:32 +01:00
Zeyu HuangandGitHub 4e7865c185 fix(i18n): add missing zh-cn translations (#964) 2024-03-06 09:37:31 +01:00
kraglehandGitHub 255abd5c88 feat(i18n): add Slovak translation (#930) 2024-02-23 23:58:07 +01:00
Gleb AandGitHub 76dc61f0d5 feat(i18n): add Belarusian translation (#937)
* feat(i18n): add Belarusian translation

* Removed .gitignore changes
2024-02-23 00:03:55 +01:00
Aman RawatandGitHub 21da06e448 feat(i18n): add Hindi translation (#889) 2023-10-28 23:59:27 +02:00
Fabian AlvarezandGitHub bda734fb23 i18n(es): minor grammatical changes (#873)
* Update es.yaml

Minus grammatically corrections

* Update es.yaml

Fix grammar mistakes
2023-09-18 23:24:52 +02:00
418d5677b1 feat(i18n): add readtime translation in Dutch (#801)
* Update nl.yaml

Added readtime translation in Dutch

* style(i18n/nl): remove duplicated translation

---------

Co-authored-by: Jimmy Cai <hi@jimmycai.com>
2023-09-03 16:10:23 +02:00
Lukáš TrkanandGitHub 40712eb781 feat(i18n): add Czech support (#793) 2023-08-27 18:03:26 +02:00
SimbaFsandGitHub 2fb534f9a6 feat(i18n): update translations for zh-tw (#786)
* sync with latest

* translate zh-tw
2023-07-15 10:13:16 +08:00
Piotr HalamaandGitHub 58559c5b3f feat(i18n): add missing plural forms for the Polish language (#818)
Add missing plural forms for the Polish language
2023-07-15 09:35:09 +08:00
ttheng3810andGitHub 4272da7ee4 feat(i18n): add footer translation for ZH-TW (#748) 2022-12-29 21:18:14 +01:00
Anh Nhat TranandGitHub ff7a56a7ac feat(i18n): add vietnamese translation (#717) 2022-12-03 13:27:55 +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
Celso MirandaandGitHub 299b80c5f8 feat(i18n): add european portuguese translation (#699)
Very subtle changes from the Brazilian Portuguese translation
2022-10-21 12:56:00 +02:00
FarisZRandGitHub b1e8472bcf feat(i18n): add categories cloud translation for Arabic (#673)
Add categories cloud translation
2022-09-29 16:30:47 +02:00
Mehedi HasanandGitHub 22d8a396ab feat(i18n): update Bengali translation (#665) 2022-09-29 16:28:58 +02:00
Daniel PessoaandGitHub 94a1f4ade0 feat(i18n): add missing pt-BR translations (#680)
* feat(i18n): Add categoriesCloud for pt-BR
2022-09-29 16:25:58 +02:00
WontoryandGitHub 72c5f4ea24 feat(i18n): added missing korean translation (categories cloud widget) (#653) 2022-08-03 20:49:10 +02:00
Sajjad ShirazyandGitHub 92a6d71ce5 feat(i18n): add Persian(Farsi) translation (#602) 2022-06-10 20:55:59 +02:00
Mehedi HasanandGitHub 49c0a2bc56 feat(i18n): add Bengali translation (#625) 2022-06-09 20:48:24 +02:00
Felix NiederwangerandGitHub 0a5cbea10f feat(i18n): add missing translation (it, nl) for categories (#614) 2022-06-05 19:01:31 +02:00
Zsombor UdvardyandGitHub add8f364e0 feat(i18n): add Hungarian translation (#584) 2022-06-05 18:00:05 +02:00
Spence ChurchillandGitHub 5e350b92e8 refactor: rename "Related contents" to "Related content" (#567) 2022-06-05 17:20:08 +02:00
Niko KöserandGitHub 14bb05c8db docs(i18n): add German translation for categories widget (#596) 2022-06-05 13:02:41 +02:00
c5eee559c2 fix(i18n/ar): update Reading Time localization for Arabic language (#527)
* update the localization based on Arabic syntax

readingTime variable updated to match the exact syntax for Arabic language

One variable in Arabic no need to add the count variable for 1 minute, there is a word to describe that specifically. 
Other variable localization updated to match Arabic grammar tenses.

* remove unnecessary leading space

Co-authored-by: Jimmy Cai <github@jimmycai.com>
2022-03-20 00:41:18 +01:00
Farrel FranqoisandGitHub 2726cf7549 feat(i18n/id): Add translation for Category Widget (#548) 2022-03-20 00:38:00 +01:00
HugooandGitHub 1cfd39c627 feat(i18n): add Catalan translation (#557) 2022-03-20 00:14:26 +01:00
HugooandGitHub bf8868c8e7 feat(i18n/es): add translation for Category widget (#558) 2022-03-20 00:06:27 +01:00
KonnyakuandGitHub da6a50ddb5 feat(i18n): add Chinese(Hong Kong) translation (#560) 2022-03-20 00:05:12 +01:00
Kacper BetańskiandGitHub 9d922272e4 feat(i18n/pl): Add translation for Category widget (#563) 2022-03-19 23:58:05 +01:00
Jimmy CaiandGitHub 7d1713d407 refactor(i18n): use lowercase language codes
Related with this Hugo issue: https://github.com/gohugoio/hugo/issues/7344
2022-03-09 15:04:24 +00:00
zhixuanandGitHub 0167edcbf2 feat(i18n): add missing ja & zh-CN translations (#538) 2022-03-07 21:33:04 +01:00
FarisZRandGitHub 47c19a0fbc feat(i18n): add Arabic translation (#157) 2022-03-04 00:28:17 +01:00