Commit Graph
211 Commits
Author SHA1 Message Date
powerfullzandGitHub e294e4ed70 fix: Firefox fallback breaks right-edge fade in related content (#1332)
* fix: Firefox fallback breaks right-edge fade in related content (#133X)

Firefox does not support scroll-driven animations by default, causing
the animation to fall back to a 0s time-based animation that jumps to
the last keyframe — flipping the fade from right to left.

Wrap animation properties in @supports (animation-timeline: scroll())
so Firefox degrades gracefully to a static right-edge fade.

* chore: fix identation

* fix: add back wrongly deleted props
2026-05-03 22:50:35 +02:00
0fc8264927 fix: comment scripts bypass cookie consent (#1308)
* fix: comment scripts bypass cookie consent

When GDPR cookie consent is enabled, the comments container is simply
hidden with CSS. However, this still allows all third-party script
tags within the container to be evaluated and downloaded by the
browser.

This PR uses the <template> tag which stops inner scripts from evaluating.
Once consent is granted, the template content is cloned and inserted
into the container, and the scripts are manually loaded in order.

* refactor(comments): move consent-gated loader to TS asset

* fix(comments): add integrity attribute to comments consent script

* style: align comments consent docs and naming

* refactor(comments): simplify script handling

---------

Co-authored-by: Jimmy Cai <jimmy@cai.im>
2026-04-26 18:51:22 +02:00
55340540b5 feat: support Artalk comment system (#1306)
* feat: support artalk comment system

* chore: change url from testingcf to cdn prefix

* refactor(comments): align artalk provider style and keep custom css overrides

* fix: update Artalk CDN links to use the correct URL

* refactor(comments): simplify Artalk implementation

* fix(artalk): update script tag to use ESM for Artalk

* fix(artalk): set locale to 'auto' for Artalk comments

* refactor: move artalk style and script link to external.toml

---------

Co-authored-by: Jimmy Cai <jimmy@cai.im>
2026-04-26 18:05:54 +02:00
powerfullzandGitHub df9253a8e9 fix(cookies): avoid banner wrapper blocking clicks (#1327) 2026-04-26 15:47:55 +02:00
powerfullzandGitHub e55168d873 fix: optimize code block selection experience (#1311) 2026-04-26 13:50:19 +02:00
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
4f2764e0a5 fix: related content overflow and horizontal scroll issues (#1305)
* fix: resolve related content card overflow and page horizontal scroll

* fix: prevent related content overflow on mobile while preserving shadow space

* fix: align related content cards and prevent shadow clipping

Expands the left margin of the related content carousel to match the main article, preserving the full card shadow. Adds a visual mask gradient to gracefully fade out the right edge.

* feat: add mask image also to left side of subsection list, which is activated when scrolling

* feat: fade out right mask image near the end of horizontal scroll

---------

Co-authored-by: Jimmy Cai <jimmy@cai.im>
2026-04-26 13:12:49 +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
JimmyandGitHub cfcdb20d17 refactor: remove custom scrollbar styles and related variables (#1304) 2026-03-08 13:23:23 +01:00
JimmyandGitHub 11aa9e349a refactor: rename article-footer to article-meta (#1293)
* refactor: rename `article-footer` to `article-meta`, and remove unnecesary structures

* fix: Update default article license URL to point to Creative Commons.
2026-03-05 17:10:35 +01:00
JimmyandGitHub 12f05571cf refactor: make article-list/compact better for term pages (#1289)
* refactor: rename article-time class to article-footer for consistency

* feat: show the number of subpages in `article-compact` when the page is a term
2026-03-05 13:43:55 +01:00
JimmyandGitHub a9a14ce815 feat: hide search results container if no keyword is given (#1288)
feat: hide search results container if no keyword is given and add typing
2026-03-05 12:52:06 +01:00
JimmyandGitHub 0ad02c5c0f refactor: add standardized spacing variables and more style cleanup (#1287)
* refactor: add standardized spacing variables and more style cleanup

* refactor: rename `spacing-xxl` to `spacing-2xl` and introduce `spacing-3xl` for consistent spacing variables.

* refactor: Migrate related content styling to use the `subsection-list` component with updated layout adjustments.

* style: adjust padding values for article list tiles.

* refactor: Introduce shadow variables and dynamic spacing to prevent shadow cutoff in list layouts.

* refactor: relocate dark scheme Mermaid variables within the root scope.
2026-03-05 12:29:48 +01:00
JimmyandGitHub 88468ad84e refactor: cleanup stylesheet (#1286)
* refactor: cleanup stylesheet

* Update assets/scss/partials/article.scss
2026-03-05 10:40:13 +01:00
22edce91ab feat: add responsive image support (#1283)
* feat: create responsive-image helper

* feat: new responsive-image helper

* feat: Implement responsive image rendering in page content using a new partial and configure image processing widths.

* feat: add `sizes` attribute for enhanced image responsiveness

* feat: add responsive image to page header too

* Check for `.Enabled` before processing image

* style: remove wrong article-list--tile width and height

* feat: add `helper/thumbnail-image` for responsive thumbnails

* feat: enable content image processing and update responsive image `sizes` attributes for improved display.

* fix: get src from the attributes so external image can work correctly

* fix: add missing data-title-escaped

* Update layouts/_partials/article/components/header.html

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

* feat: remove default `true` for thumbnail resize parameter.

* Update layouts/_markup/render-image.html

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

* Update layouts/_partials/helper/thumbnail-image.html

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

* add original width and height to thumbnail pictures, for case that resize is not enabled

* Update layouts/_partials/helper/thumbnail-image.html

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

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-04 23:32:33 +01:00
JimmyandGitHub 2be5b48324 feat(list): ability to show article tags on homepage (#1270)
* feat(list): ability to show article tags on homepage

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

* Disable showTags by default
2026-02-19 17:45:09 +01: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
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