-
Notifications
You must be signed in to change notification settings - Fork 121
Add a template for blockquote alerts (aka callouts) #2977
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| {{ $emojis := dict | ||
| "caution" ":bangbang:" | ||
| "important" ":information_source:" | ||
| "note" ":memo:" | ||
| "tip" ":bulb:" | ||
| "warning" ":warning:" | ||
| }} | ||
|
|
||
| {{ if eq .Type "alert" }} | ||
| <blockquote class="alert alert-{{ .AlertType }}"> | ||
| <p class="alert-heading"> | ||
| {{ transform.Emojify (index $emojis .AlertType) }} | ||
| {{ with .AlertTitle }} | ||
| {{ . }} | ||
| {{ else }} | ||
| {{ or (i18n .AlertType) (title .AlertType) }} | ||
| {{ end }} | ||
| </p> | ||
|
|
||
| <div class="alert-content"> | ||
| {{ .Text }} | ||
| </div> | ||
| </blockquote> | ||
| {{ else }} | ||
| <blockquote> | ||
| {{ .Text }} | ||
| </blockquote> | ||
| {{ end }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,3 +117,58 @@ article { | |
| #content-wrap { | ||
| padding-bottom: var(--footer-height); | ||
| } | ||
|
|
||
| /* Styles for blockquote alerts, aka admonitions or callouts */ | ||
| // Source: https://github.com/KKKZOZ/hugo-admonitions | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any specific reason not to use the module instead of c/p?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not especially. There are several more types of callouts in the module and definitely more robust styling. However, I was just looking to add the most basic types. Note that the template itself is from an example in the Hugo docs (only a couple of lines changed). It's just the CSS I copied from the module (one line changed). Do you suggest adding the module directly?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kingthorin I replied @thc202 earlier. My comment is supposed to be up there just before yours, although I added it using the mobile app. Maybe that's why it's not showing up? Anyway, here it is again:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would be preferable than duplicate functionality IMHO. |
||
|
|
||
| // Alert colors | ||
| $alert-colors: ( | ||
| caution: #e64553, | ||
| important: #7D4DDA, | ||
| note: #096ae1, | ||
| tip: #179299, | ||
| warning: #df8e1d | ||
| ); | ||
|
|
||
| // Base alert styles | ||
| .alert { | ||
| margin: 1rem 0; | ||
| border-radius: 4px; | ||
| box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); | ||
| border-left-width: 4px; | ||
| border-left-style: solid; | ||
| padding: 0.8rem 1rem; | ||
| background: rgba(0, 0, 0, 0.05); | ||
| font-size: 1rem; | ||
|
|
||
| p { | ||
| margin: 0; | ||
| } | ||
| } | ||
|
|
||
| // Alert headers | ||
| .alert-heading { | ||
| font-weight: bold; | ||
| font-size: 1.1rem; | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 0.5rem; | ||
| } | ||
|
|
||
| // Alert content | ||
| .alert-content > p { | ||
| padding-top: 0.5rem;; | ||
| } | ||
|
|
||
| // Generate alert types | ||
| @each $type, $color in $alert-colors { | ||
| .alert-#{$type} { | ||
| border-left-color: $color; | ||
|
|
||
| .alert-heading { | ||
| color: $color; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /* END Styles for blockquote alerts */ | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@psiinon I changed the emoji for "note" from 📄 to 📝. I was thinking the latter looks more colourful and is more noticeable (matches the other icons better, I think).