Skip to content

Add support for blockquote alerts in layout files #3073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Wryhder
Copy link
Contributor

@Wryhder Wryhder commented May 5, 2025

I'd previously suggested using short codes as an upgrade from the current render hook template (which only works in Markdown content), to add support for blockquote alerts in both HTML/Markdown content and layout files. But it turns out short codes don't work in layout files.

So this PR includes a partial template that can be used directly in layout files. Then, a short code that calls the partial can be used in Markdown content files. I've included documentation (work-in-progress) in the README on how to use both the partial and the short code.

# Current syntax (markdown only)
[!NOTE]
> Useful information that users should know, even when skimming content.

# New syntax - short code in markdown 
{{< blockquote-alert type="note" title="Optional custom title">}}
Useful information that users should know, even when skimming content.
{{< /blockquote-alert >}}

# New syntax - partial in layout files
{{ partial "blockquote-alert.html" (dict
    "type" "tip"
    "title" "Pro Tip"
    "content" "<p>Use partials to avoid repeating logic.</p>"
) }}

Just for reference, here's what the alerts look like again (image borrowed from PR #2977 ). They'll be pretty much the same as before:

callouts_changed emoji

TODO:

  1. I've tested the short code in a Markdown content file, and the partial in a layout file. Probably need to test the short code in HTML content files, and the partial in other partials.
  2. It makes sense to remove the current render hook template and update any existing alerts to use the new syntax, but please let me know if it should stay, so that it's also possible to keep using the current syntax.

PS: I'm still learning my way around Hugo, so please let me know if I've got anything mixed up.

@psiinon
Copy link
Member

psiinon commented May 5, 2025

Logo
Checkmarx One – Scan Summary & Detailsc4bef20f-701d-454b-a651-6d15c3b6424f

Great job, no security vulnerabilities found in this Pull Request

@psiinon
Copy link
Member

psiinon commented May 9, 2025

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants