Skip to content

Admonition shortcodes for note, tip and warning - #130

Open
Sieboldianus wants to merge 3 commits into
Track3:masterfrom
Sieboldianus:feat-admonition-cleaned
Open

Admonition shortcodes for note, tip and warning#130
Sieboldianus wants to merge 3 commits into
Track3:masterfrom
Sieboldianus:feat-admonition-cleaned

Conversation

@Sieboldianus

@Sieboldianus Sieboldianus commented Apr 28, 2020

Copy link
Copy Markdown
Contributor

I've pulled together shortcodes for note, tip and warning and used those for a while now in my blog:

image

The base code comes from the gohugoio-theme (e.g. used in the docs) from where I updated to match the Hermit Theme.

To produce the above, the following code in a markdown/content file is used:

{{% note %}}
Here is a piece of information I would like to draw your **attention** to.
{{% /note %}}

{{% warning %}}
This is a warning, which should be reserved for *important* information like breaking changes.
{{% /warning %}}

{{% tip %}}
Here's a bit of advice to improve your productivity with Hugo.
{{% /tip %}}

I've also added three svg-icons from the fontawesome, among others, explained in a blog post here.

I tried to include it in the most flexible way: fontawesome icons are only included as svg, and only those three (not the full library). There're 3 new colors added to _predefined.scss:

$admonition-note :#F8E45C;
$admonition-tip : #0594CB;
$admonition-warning :#ff725c;

Any admonition scss is stored in a separate file, admonition.scss.

Happy to discuss the colors or style, if anyone is interested in this feature. E.g.: I decided against round-corners, since I found that the theme has already so many round corners.

@Sieboldianus

Copy link
Copy Markdown
Contributor Author

Some more tests: switching colors for note and tip - I think this may look better:
image

@Sieboldianus
Sieboldianus force-pushed the feat-admonition-cleaned branch from 2fe0cc5 to 44f4c31 Compare April 29, 2020 07:32
@Sieboldianus

Sieboldianus commented Apr 29, 2020

Copy link
Copy Markdown
Contributor Author

Another option with reduced colors, perhaps with a cleaner look:

image

@Sieboldianus
Sieboldianus force-pushed the feat-admonition-cleaned branch from a78fdc3 to 346e8e8 Compare April 29, 2020 08:52
@Sieboldianus Sieboldianus changed the title Add admonition shortcodes for note, tip and warning Admonition shortcodes for note, tip and warning Apr 29, 2020
1bl4z3r added a commit to 1bl4z3r/hermit-V2 that referenced this pull request Oct 21, 2023
pingz pushed a commit to pingz/hermit-V2 that referenced this pull request Apr 11, 2025
xuekepei added a commit to xuekepei/hermit that referenced this pull request Aug 16, 2026
1. meta description (upstream issue Track3#119 — issue only, no PR)
   The theme never emitted <meta name="description">, so params.description
   went unused and Lighthouse reported "document does not have a meta
   description". baseof.html now falls back .Description -> .Summary ->
   .Site.Params.description.

2. Analytics into head (upstream PR Track3#151)
   Loads earlier, losing fewer hits from visitors who leave quickly.

3. code-copy with table layout (upstream PR Track3#137)
   With markup.highlight.lineNos enabled chroma emits a <table> and copying
   grabs the line numbers too; select only the code cell in that case.

4. Admonition shortcodes (upstream PR Track3#130)
   Adds note / tip / warning. Four defects in the original PR are fixed:
   - all three shared one blue border colour, making them indistinguishable
     -> coloured per semantic
   - content background used $highlight-grey, ~2.5:1 against $text, below
     the WCAG AA 4.5:1 minimum -> $light-grey, ~6.5:1
   - vertical margins sat on .admonition-content so the left border did not
     enclose the content -> moved to the container
   - .Inner abutted the <div>, so CommonMark's HTML block rule skipped
     inline Markdown parsing and bold/links inside the box stayed literal
     -> separated by blank lines
   Also drops $_hugo_config, deprecated since Hugo 0.55.

Verified on Hugo v0.164.0+extended: builds with no warnings, all three
colours compile, and Markdown inside the boxes renders.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant