Commit Graph
746 Commits
Author SHA1 Message Date
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 8e3687431f fix: ensure taxonomy widget title is only linked if a taxonomy page exits (#1314)
fix: ensure taxonomy widget title is only linked if a taxonomy page exists
2026-03-21 12:01:29 +01:00
JimmyandGitHub cfcdb20d17 refactor: remove custom scrollbar styles and related variables (#1304) 2026-03-08 13:23:23 +01:00
0c941ebb04 fix: skip inaccessible images to avoid build failure (#1301)
* skip inaccessible images to avoid build failure

* undo changes to $result and $local

* fix: initialize $resource as a dictionary instead of an empty string

* feat: add external image processing timeout configuration

---------

Co-authored-by: Jimmy Cai <jimmy@cai.im>
2026-03-08 13:18:21 +01:00
JimmyandGitHub f13c478718 fix: check if resource exists before accessing .RelPermalink (#1299)
* fix: check if resource exists before accessing `.RelPermalink`

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

* Set default value of $result in `helper/image` to dict
2026-03-06 00:13:13 +01:00
JimmyandGitHub bde2914dec chore: Remove featuredImageField from configuration (#1298)
chore: Remove `featuredImageField` from configuration.
2026-03-05 23:56:27 +01:00
JimmyandGitHub f5adf4a273 fix: do not display the date of term pages (#1296) 2026-03-05 18:25:04 +01:00
JimmyandGitHub 07fa7615eb refactor: simplify article-list/tile partial context passing (#1295)
refactor: simplify `article-list/tile` partial context passing and internal usage.
2026-03-05 18:15:05 +01:00
JimmyandGitHub 628bb9a501 feat: use images.AutoOrient in helper/image (#1294)
* feat: use images.AutoOrient in `helper/image`

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

* fix: check if IsImageResourceProcessable before using filter

* remove local field

* feat: add configurable image auto-orientation via a new `autoOrient` parameter in site configuration
2026-03-05 17:58:40 +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 25bf63778c feat: use thumbnail in section and links image (#1291)
* feat: use thumbnail for section image

* feat: use thumbnail in links image

* fix typo
2026-03-05 13:57:37 +01:00
JimmyandGitHub a95d0e7c85 refactor: use helper/image in links.html (#1290)
* refactor: use `helper/image` in `links.html`

* fix: check for $image existence before accessing
2026-03-05 13:51:34 +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
230a28fa8d feat(widgets): link widget titles to their respective pages (#1277)
- archives.html: Link the "Archives" title to the archives page,
  consistent with how individual year links already work
- taxonomy.html: Change showLink default from false to true so
  tag-cloud and categories widget titles link to their taxonomy
  listing pages by default

Widget titles are the primary affordance users interact with, so
linking them to the full listing page improves navigation. The
showLink param can still be set to false to disable this.

Co-authored-by: delize <4028612+delize@users.noreply.github.com>
2026-03-05 13:18:32 +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
JimmyandGitHub 3dae60ac7a fix: use IsImageResourceWithMeta to check whether image has width / height attributes (#1285) 2026-03-05 09:23:47 +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 78800c7379 fix: keep external image url, and use reflect.IsImageResourceProcessable to check for svg and other non-processable image formats (#1282)
* fix: keep external image url, and use reflect.IsImageResourceProcessable to check for svg

* build: update Hugo version to 0.157.0 in the build script.

* docs: remove `Local` return value and simplify `Resource` description in image helper

* Check for reflect.IsImageResourceProcessable before getting color from image

* chore: update minimum Hugo version to 0.157.0
2026-03-04 13:05:17 +01:00
a0bd0073bb fix: reading time not displaying in article/components/details partial (#1278)
Fix reading time not displaying due to .Site context in dict partial

The details.html partial receives a dict context via:
  partial "article/components/details" (dict "Page" $Page "IsList" $IsList)

When the dot context is a dict, .Site resolves to nil, so
.Site.Params.article.readingTime always returns empty/false,
causing the reading time to never display.

Lines 40 and 67 of the same file already correctly use
$Page.Site.Params — this fixes line 31 to be consistent.

Co-authored-by: delize <4028612+delize@users.noreply.github.com>
2026-03-04 11:58:09 +01:00
Jimmy Cai 3ca74956a6 ci: update Hugo version to 0.156.0 2026-02-19 17:54:42 +01:00
Jimmy Cai 22b8d091f4 doc(demo): disable cookie consent 2026-02-19 17:50:48 +01:00
JimmyandGitHub bd7a34966c refactor(sidebar): drop support for .Pre and remove old codes (#1271)
* refactor(sidebar): drop support for .Pre and remove old codes

* Simplify
2026-02-19 17:49:50 +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
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
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 2058c1ff6d refactor: create a generic taxonomy widget (#1268)
* refactor: introduce a generic taxonomy widget and refactor existing category and tag cloud widgets to use it.

* feat: Implement optional title linking for taxonomy widgets and enable parameter customization for taxonomy partials.

* refactor: remove fallback to taxonomy page title for widget display

Because this field always exists. I think it's better to let user customize via widget params

* Update layouts/_partials/widget/taxonomy.html

* refactor: check for .Params.taxonomy existence before accessing
2026-02-18 18:56:15 +01:00
d6448148cf feat: add option to set a custom canonical url (#1267)
* add option to set a custom canonical url

* style: use `with` to load cannonicalurl

* style: change to canonicalUrl

Frontmatter is case-insensitive so it does not matter

---------

Co-authored-by: FarisZR <35614734+FarisZR@users.noreply.github.com>
2026-02-17 20:01:23 +01:00
JimmyandGitHub 475c956fd6 style: format TOML files (#1266)
* style: format TOML files

* style: format wrangler.toml
2026-02-17 19:20:09 +01:00
5e57b5ad29 feat(comment): add support for Comentario (#1088)
* Add support for comentario.

* feat: add Comentario client configuration options in TOML

* fix: format theme attribute in comentario comments component

---------

Co-authored-by: Jimmy Cai <jimmy@cai.im>
2026-02-17 19:09:18 +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
0cefe05973 fix: preload Google Fonts to reduce layout shift (#1215)
* fix: preload Google Fonts to reduce layout shift

Move font loading from footer JS to head with preconnect and preload
hints. This reduces CLS by ensuring fonts load earlier in the page
lifecycle instead of being dynamically inserted after footer loads.

* style: reorder custom font inclusion in head template

---------

Co-authored-by: delize <4028612+delize@users.noreply.github.com>
Co-authored-by: Jimmy Cai <jimmy@cai.im>
2026-02-17 18:03:53 +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
Jimmy Cai 99a8fd9013 docs: Update demo and documentation URLs 2026-02-17 13:48:49 +01:00
JimmyandGitHub 7f47cdf165 fix: check if favicon exists before accessing permalink (#1259) 2026-02-01 13:11:42 +01:00
JimmyandGitHub 768e7de697 refactor: update RSS template to the latest one given by Hugo, and change page output logic (#1257)
* refactor: rename `home.rss.xml` to `rss.xml`

* refactor: update RSS template to the latest one given by Hugo.

Output pages with the same logic as in normal site by using `helper/pages`
2026-01-30 15:27:32 +01:00
JimmyandGitHub 00069b2c45 feat: add muted attribute and refine autoplay condition for video shortcode (#1256) 2026-01-30 15:09:33 +01:00
JimmyandGitHub 31022581d8 refactor: image logic in page (#1255)
* fix: add SVG check in helper/image before accessing .Width and .Height

* refactor: drop image resizing logic in render-image, and use helper/image to process image

* fix: render-image $permalink not correct
2026-01-30 15:07:14 +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 bc54cecf0a refactor: centralize page filtering logic, and allow sort by lastmod (#1250)
* refactor: migrate page visibility control from `Params.hidden` to the new `build.list` parameter.

* refactor: centralize page filtering logic into a new `helper/pages.html` partial

* feat: introduce `SortBy` parameter to enable sorting pages by last modified date

* refactor: extract page sorting logic into a new `pages-sort.html` partial
2026-01-27 12:34:15 +01:00
JimmyandGitHub deceb17144 refactor: migrate page visibility control from Params.hidden to the new build.list parameter. (#1249)
* refactor: migrate page visibility control from `Params.hidden` to the new `build.list` parameter.

* Rename rss.xml to home.rss.xml
2026-01-27 12:00:40 +01:00
Jimmy Cai dc0d105e7c fix: correct global site context access for the home page link in the sidebar 2026-01-27 00:05:05 +01:00
JimmyandGitHub 33b7de9457 refactor: use .Site.Home.RelPermalink for home page links in the sidebar (#1248)
refactor: use `.Site.Home.RelPermalink` for home page links in the sidebar.
2026-01-26 23:59:40 +01:00
JimmyandGitHub 7d4bfa9fc0 refactor: simplify sidebar avatar configuration and don't resize (#1247) 2026-01-26 23:58:18 +01:00
JimmyandGitHub ab17b22c77 refactor: get favicon from assets folder (#1246) 2026-01-26 23:49:27 +01:00