Commit Graph
359 Commits
Author SHA1 Message Date
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
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
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
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
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 3a03d69502 refactor: move default parameter values from template logic to params.toml (#1244) 2026-01-26 15:50:18 +01:00
Jimmy Cai 3b753c9cc0 release: prepare for v4.0.0 2026-01-26 14:20:10 +01:00
Jimmy 0542fed42e fix: avoid site name appearing twice in the title (#1240) 2026-01-26 11:19:05 +01:00
JimmyandGitHub 35cba14cde feat: if current page has i18n version, language switcher will redirect to there instead of homepage (#1237)
feat: if current page has i18n version, language switcher will redirect to there
2026-01-25 23:55:50 +01:00
Jimmy Cai d002c0d0d9 refactor: also remove image resize logic in search.json 2026-01-25 23:44:47 +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 067bcdb370 refactor: image handling logic + support for external images (#1235)
* refactor: simplify image partial logic, remove generation of different image sizes

* Remove `defaultImage.opengraph` configuration from `params.toml`.
2026-01-25 23:29:41 +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 9d9ecc4d00 fix: error when no page is found (#1234) 2026-01-25 23:12:28 +01:00
JimmyandGitHub 5f1ab2bc76 refactor: migrate to new template system introduced in Hugo v0.146.0 (#1232)
See: https://gohugo.io/templates/new-templatesystem-overview/
2026-01-25 22:42:00 +01:00
JimmyandGitHub 633c8c6b9f refactor: Use RelPermalink for internal links (#1231) 2026-01-25 22:31:58 +01:00
Jimmy Cai ffab83a637 release: 3.34.0 2026-01-25 17:55:45 +01:00
JimmyandGitHub 9add062300 refactor: centralize pagination logic (#1227)
* refactor: centralize pagination logic into a new helper partial used for page titles and index display

* fix: list.html does not exclude hidden pages

* refactor: Simplify title generation logic
2026-01-25 17:54:13 +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 f804db2c80 fix: load mermaid partial without cache (#1226) 2026-01-25 16:50:33 +01:00
Jimmy d6ced60f51 release: 3.33.0 2025-12-22 16:17:42 +00:00
JimmyandGitHub dc36aa60a9 fix: remove hidden posts using where keyword (#1212) 2025-12-22 17:12:34 +01:00
ba9a5caa16 feat: add support for Mermaid diagrams in Markdown content (#1186)
* Add support for Mermaid diagrams in markdown content

This commit introduces native Mermaid diagram rendering to the theme.

Following Hugo’s official documentation, a new custom code block renderer
(`render-codeblock-mermaid.html`) was added under `layouts/_default/` to
detect Mermaid code blocks and inject the necessary script flag into the
page context.

Additionally, the `baseof.html` template now conditionally includes the
Mermaid JS module from the CDN when a page contains a Mermaid diagram:

  {{ if .Store.Get "hasMermaid" }}
    <script type="module">
      import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
      mermaid.initialize({ startOnLoad: true, theme: 'neutral' });
    </script>
  {{ end }}

This enables rendering of fenced code blocks using the `mermaid` language
in markdown files without requiring any external preprocessing.

* Create article/components/mermaid and fix script version

---------

Co-authored-by: Jimmy <jimmy@cai.im>
2025-12-22 13:40:33 +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
7df31001af fix(theme): Adjust Cusdis widget scrollbar and background to match Stack theme (#1204)
* fix: adjust cusdis scrollbar styling and background for stack theme

* feat: dynamically set cusdis background color

---------

Co-authored-by: Jimmy <jimmy@cai.im>
2025-12-21 20:55:09 +01:00
Jimmy 73ccacec4d release: 3.32.0 2025-11-01 21:15:56 +00:00
JimmyandGitHub 2612ca87dc feat: allow specify alt for link's image (#1198) 2025-11-01 22:14:52 +01:00
CelesteandGitHub e8fc315ead fix: decode special characters in the search bar on 404 pages (#1098)
An extremely simple fix to decode special characters
2025-11-01 22:01:24 +01:00
AMomentandGitHub dd3bb1ea13 feat: render math formula for the table of contents (#1137)
Add math formula render to table of contents

Add element (.widget--toc) to be rendered by KaTeX
2025-11-01 21:54:06 +01:00
Andreas DeiningerandGitHub 291fe5fd7e feat: remove deprecated Hugo templates and shortcode usage (#1150)
Adapt site to latest hugo version 0.147.1
2025-11-01 21:49:15 +01:00
AradielandGitHub 5a10223f4c fix: modify sidebar link active conditions (needs to be the same page URL) (#1153)
Sidebar link active conditions - needs to be the same page
2025-11-01 21:41:10 +01:00
powerfullzandGitHub c413980b89 fix(twikoo): certain Twikoo elements wouldn’t automatically switch colours in dark mode and update to Twikoo version 1.6.44 (#1163) 2025-11-01 21:35:09 +01:00
Christian Martínez de la RosaandGitHub 6d98e8463f fix: use localized title for categories taxonomy in archives page (#1158)
closes #1157
2025-11-01 21:30:37 +01:00
Terence EdenandGitHub f824d08f6f fix: semantic <time> by adding datetime attribute (#1184)
Fix semantic <time>

The HTML validator was throwing an error because there was no valid datetime attribute.
2025-11-01 20:53:37 +01:00
JimmyandGitHub 8cb1646198 style: remove unused count class in tag cloud (#1195) 2025-10-31 23:48:40 +01:00
Jimmy 9e96c6e975 release: 3.31.0 2025-09-10 10:14:29 +00:00
Gleb A.andGitHub 47832083d8 refactor(comments): use includes instead of indexOf to improve readability (#1128)
* fix(disqusjs): refactor local DisqusJS loading check for improved readability

* fix(gitalk): refactor local Gitalk loading check for improved readability
2025-05-21 12:52:47 +02:00
LparksiandGitHub d9acd77015 feat(comment/waline): add support for Waline's turnstileKey (#1140)
* fix: Added support for waline's turnstileKey

* style: remove extra space in waline.html
2025-05-21 12:31:22 +02:00
Bernat Borràs CivilandGitHub 06aa627d3c fix(article): date translation on compact mode (#1149)
* Fix translation

* Revert jsconfig
2025-05-21 12:25:11 +02:00
Jimmy Cai 9e6b7b22a9 release: 3.30.0 2025-01-23 22:55:27 +01:00
JimmyandGitHub f1ab6c6aba fix(giscus): no longer use $.Language.LanguageCode for the language of Giscus (#1118)
fix(giscus): rollback https://github.com/CaiJimmy/hugo-theme-stack/pull/1075

User can still customize the language used for Giscus using `.Site.Params.comments.giscus.lang` parameter.
2025-01-23 22:54:37 +01:00