From a1bd12d72dc73806d988f3f1be9e45abe08746ad Mon Sep 17 00:00:00 2001 From: John Bowdre Date: Tue, 15 Aug 2023 20:27:46 -0500 Subject: [PATCH] implement notices directly in site --- config/_default/config.toml | 2 +- layouts/shortcodes/notice.html | 15 +++++ static/css/custom.css | 120 +++++++++++++++++++++++++++++++++ themes/hugo-notice | 1 - 4 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 layouts/shortcodes/notice.html create mode 100644 static/css/custom.css delete mode 160000 themes/hugo-notice diff --git a/config/_default/config.toml b/config/_default/config.toml index 507a5a6..b2073ef 100644 --- a/config/_default/config.toml +++ b/config/_default/config.toml @@ -1,5 +1,5 @@ baseURL = "https://runtimeterror.dev" -theme = [ "hugo-cloak-email", "hugo-notice", "risotto"] +theme = [ "hugo-cloak-email", "risotto"] title = "runtimeterror" author = "ops" copyright = "© 2023 [runtimeterror](https://runtimeterror.dev)" diff --git a/layouts/shortcodes/notice.html b/layouts/shortcodes/notice.html new file mode 100644 index 0000000..80806f3 --- /dev/null +++ b/layouts/shortcodes/notice.html @@ -0,0 +1,15 @@ +{{/* Built on hugo-notice by Nicolas Martignoni: https://github.com/martignoni/hugo-notice */}} +{{/* Available notice types: warning, info, note, tip */}} +{{- $noticeType := .Get 0 | default "note" -}} +{{/* Workaround markdownify inconsistency for single/multiple paragraphs */}} +{{- $raw := (markdownify .Inner | chomp) -}} +{{- $block := findRE "(?is)^<(?:address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h(?:1|2|3|4|5|6)|header|hgroup|hr|li|main|nav|noscript|ol|output|p|pre|section|table|tfoot|ul|video)\\b" $raw 1 -}} +{{/* Count how many times we've called this shortcode and load the css if it's the first time */}} +{{- if not ($.Page.Scratch.Get "noticecount") -}} +
+{{- end -}} +{{- $.Page.Scratch.Add "noticecount" 1 -}} +
+

{{ if len .Params | eq 2 }}{{ .Get 1 }}{{ end }}

+{{- if or $block (not $raw) }}{{ $raw }}{{ else }}

{{ $raw }}

{{ end -}} +
diff --git a/static/css/custom.css b/static/css/custom.css new file mode 100644 index 0000000..95245f3 --- /dev/null +++ b/static/css/custom.css @@ -0,0 +1,120 @@ +/* Notice CSS Built on hugo-notice by Nicolas Martignoni: https://github.com/martignoni/hugo-notice */ +.notice { + --root-color: #444; + --root-background: #eff; + --title-color: #fff; + --title-background: #7bd; + --warning-title: #c33; + --warning-content: #fee; + --info-title: #fb7; + --info-content: #fec; + --note-title: #6be; + --note-content: #e7f2fa; + --tip-title: #5a5; + --tip-content: #efe; +} + +@media (prefers-color-scheme: dark) { + .notice { + --root-color: #ddd; + --root-background: #eff; + --title-color: #fff; + --title-background: #7bd; + --warning-title: #800; + --warning-content: #400; + --info-title: #a50; + --info-content: #420; + --note-title: #069; + --note-content: #023; + --tip-title: #363; + --tip-content: #121; + } +} + +body.dark .notice { + --root-color: #ddd; + --root-background: #eff; + --title-color: #fff; + --title-background: #7bd; + --warning-title: #800; + --warning-content: #400; + --info-title: #a50; + --info-content: #420; + --note-title: #069; + --note-content: #023; + --tip-title: #363; + --tip-content: #121; +} + +.notice { + padding: 18px; + line-height: 24px; + margin-bottom: 24px; + border-radius: 4px; + color: var(--root-color); + background: var(--root-background); +} + +.notice p:last-child { + margin-bottom: 0; +} + +.notice-title { + margin: -18px -18px 12px; + padding: 4px 18px; + border-radius: 4px 4px 0 0; + font-weight: 700; + color: var(--title-color); + background: var(--title-background); +} + +.notice.warning .notice-title { + background: var(--warning-title); +} + +.notice.warning { + background: var(--warning-content); +} + +.notice.info .notice-title { + background: var(--info-title); +} + +.notice.info { + background: var(--info-content); +} + +.notice.note .notice-title { + background: var(--note-title); +} + +.notice.note { + background: var(--note-content); +} + +.notice.tip .notice-title { + background: var(--tip-title); +} + +.notice.tip { + background: var(--tip-content); +} + +.icon-notice { + display: inline-flex; + align-self: center; + margin-right: 8px; +} + +.icon-notice img, +.icon-notice svg { + height: 1em; + width: 1em; + fill: currentColor; +} + +.icon-notice img, +.icon-notice.baseline svg { + top: 0.125em; + position: relative; +} diff --git a/themes/hugo-notice b/themes/hugo-notice deleted file mode 160000 index cce7afd..0000000 --- a/themes/hugo-notice +++ /dev/null @@ -1 +0,0 @@ -Subproject commit cce7afd430d49fe01ad6e2c006c3518fddc8ad77