* 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>
* 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
* 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
* 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>
* 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>
* 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
* Enhance text rendering with autospace properties
Added text autospace properties for better text rendering for CJK characters.
* Update text-autospace and text-spacing properties
* 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
* Consistent svg coloring in menu
* fix: use `currentColor` to avoid breaking style of active element
---------
Co-authored-by: Jimmy Cai <hi@jimmycai.com>
* 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
* 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
* 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>