Skip to content

feat: add markdown alerts support#1221

Merged
CaiJimmy merged 6 commits intoCaiJimmy:masterfrom
Bigstool:markdown-alerts
Feb 18, 2026
Merged

feat: add markdown alerts support#1221
CaiJimmy merged 6 commits intoCaiJimmy:masterfrom
Bigstool:markdown-alerts

Conversation

@Bigstool
Copy link
Copy Markdown
Contributor

@Bigstool Bigstool commented Jan 5, 2026

Add support for the following markdown alerts utilizing the Hugo blockquote render hooks:

Note

Highlights information that users should take into account, even when skimming.

Tip

Optional information to help a user be more successful.

Important

Crucial information necessary for users to succeed.

Warning

Critical content demanding immediate user attention due to potential risks.

Caution

Negative potential consequences of an action.

With:

> [!NOTE]  
> Highlights information that users should take into account, even when skimming.

> [!TIP]
> Optional information to help a user be more successful.

> [!IMPORTANT]  
> Crucial information necessary for users to succeed.

> [!WARNING]  
> Critical content demanding immediate user attention due to potential risks.

> [!CAUTION]
> Negative potential consequences of an action.

Preview:
Screenshot 2026-01-06 at 01-11-46 20260106 Md Warning

Screenshot 2026-01-06 at 01-11-53 20260106 Md Warning

Reference:
https://github.com/orgs/community/discussions/16925

Related:
#1085

@AiratTop
Copy link
Copy Markdown
Contributor

Looks great! Waiting for merge

@tats-u
Copy link
Copy Markdown
Contributor

tats-u commented Feb 2, 2026

GitHub made a foolish decision to set the caution color as red instead of yellow. Stack should not follow in their footsteps.

ANSI

From: https://www.muirgraphics.com/2016/08/difference-life-death-choosing-right-safety-signal-words/

MHI0111-OABLOG-SafetySigns-750x375-1

From: http://www.overheadlifting.org/understanding-safety-signs-and-overhead-lifting-equipment-hazards/

Image

From: http://www.ishiimark.co.jp/s-label-top.html

GitLab, Redmine, Docusaurus, and Starlight (Astro) sets the caution color as yellow.

Docusaurus and Starlight provides "Danger" as the red alert.

@Bigstool
Copy link
Copy Markdown
Contributor Author

Bigstool commented Feb 2, 2026

@tats-u Fair point! I agree that GitHub’s color choices can be questionable. For this PR, my main goal is to focus on adding basic support for markdown alerts first, and leave further refinements for follow-ups.

This topic also seems to be actively discussed across different projects, with no clear consensus yet. For example, instead of using yellow for caution, GitLab seems to have swapped the orange and red colors between caution and warning. Docusaurus apparently substituted caution with danger, and Starlight substituted warning with caution. Different platforms adopt different mappings for caution and warning, which makes it difficult to settle on a single “correct” scheme at this stage. Given that, I’d prefer to keep this PR focused on implementing the core feature.

Additionally, the current code should also be quite easy to customize the colors or add new alert types later when needed.

@tats-u
Copy link
Copy Markdown
Contributor

tats-u commented Feb 2, 2026

Docusaurus apparently substituted caution with danger

No, "warning" used to be red: https://docusaurus.io/docs/next/migration/v3#admonition-warning
"caution" has been yellow and was replaced with "warning" changed to yellow.

quite easy to customize the colors

Why don't you mention emojis here? They're hard-coded and can't be touched by CSS. "🚨" is more severe than "⚠️".

We should at least switch between GitHub's defected coloring/order and ISO's gold standard coloring/order by a simple configuration.

@Bigstool
Copy link
Copy Markdown
Contributor Author

Bigstool commented Feb 2, 2026

@tats-u

No, "warning" used to be red

I think this illustrates my point nonetheless.

Why don't you mention emojis here? They're hard-coded and can't be touched by CSS. "🚨" is more severe than "⚠️".

Please kindly refer to the corresponding file of this commit. Simply change the emojis there.

Once again, I agree that the color scheme discrepancy is a fair and reasonable point for further discussions in a follow-up. For this PR, I want to focus on the core implementation of this feature. Thanks again for bringing your insights.

@tats-u
Copy link
Copy Markdown
Contributor

tats-u commented Feb 15, 2026

I don't think someone who just wants to use this theme would easily modify the code examples to assign the same icon to multiple notice types.

@Bigstool
Copy link
Copy Markdown
Contributor Author

Bigstool commented Feb 16, 2026

@tats-u
It might still be better than not having markdown alerts support at all. As I have mentioned multiple times, this PR focuses on the core implementation of the feature. Thank you for your constructive feedback.

Copy link
Copy Markdown
Owner

@CaiJimmy CaiJimmy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I have made some changes so that the icon and color are customisable

@CaiJimmy CaiJimmy merged commit 4702951 into CaiJimmy:master Feb 18, 2026
@CaiJimmy
Copy link
Copy Markdown
Owner

Regarding the discussion about the coloring, I agree that it is debatable. However, now that it's available for user customization via CSS variables, it's a little less critical.

jin-li added a commit to jin-li/hugo-theme-stack that referenced this pull request Mar 4, 2026
* refactor: create a generic `taxonomy` widget (CaiJimmy#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

* feat: add markdown alerts support (CaiJimmy#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>

* feat(i18n): add i18n support for Markdown alert (CaiJimmy#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

* feat: add GDPR cookie consent banner (CaiJimmy#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 CaiJimmy#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>

* feat(list): ability to show article tags on homepage (CaiJimmy#1270)

* feat(list): ability to show article tags on homepage

closes CaiJimmy#880

* Disable showTags by default

* refactor(sidebar): drop support for .Pre and remove old codes (CaiJimmy#1271)

* refactor(sidebar): drop support for .Pre and remove old codes

* Simplify

* doc(demo): disable cookie consent

* ci: update Hugo version to 0.156.0

---------

Co-authored-by: Jimmy <jimmy@cai.im>
Co-authored-by: Bigstool <20697772+Bigstool@users.noreply.github.com>
Co-authored-by: Andrew Doering <delize@users.noreply.github.com>
Co-authored-by: delize <4028612+delize@users.noreply.github.com>
jin-li pushed a commit to jin-li/hugo-theme-stack that referenced this pull request Mar 5, 2026
* 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>
powerfullz pushed a commit to powerfullz/hugo-theme-stack-upstream that referenced this pull request Mar 10, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants