From eb0b427a79b68ffb47f8b4d91ca2d869b0f8fc6e Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sun, 24 Jul 2022 01:47:43 +0200 Subject: [PATCH] Use custom notice style in favor of hugo-notice --- .gitmodules | 3 -- config.yml | 2 - layouts/shortcodes/notice.html | 45 ++++++++++++++++++++++ static/src/scss/_notice.scss | 69 ++++++++++++++++++++++++++++++++++ static/src/scss/style.scss | 1 + themes/hugo-notice | 1 - 6 files changed, 115 insertions(+), 6 deletions(-) delete mode 100644 .gitmodules create mode 100644 layouts/shortcodes/notice.html create mode 100644 static/src/scss/_notice.scss delete mode 160000 themes/hugo-notice diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 66592a1..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "themes/hugo-notice"] - path = themes/hugo-notice - url = https://github.com/martignoni/hugo-notice.git diff --git a/config.yml b/config.yml index 5381f7a..fb43c5d 100644 --- a/config.yml +++ b/config.yml @@ -5,8 +5,6 @@ title: "ItsDrike" staticDir: "static/build" assetDir: "static/build" -theme: ["hugo-notice"] - buildFuture: true MetaDataFormat: yaml markup: diff --git a/layouts/shortcodes/notice.html b/layouts/shortcodes/notice.html new file mode 100644 index 0000000..83f49c8 --- /dev/null +++ b/layouts/shortcodes/notice.html @@ -0,0 +1,45 @@ +{{/* Available notice types: warning, info, note, tip */}} +{{- $noticeType := .Get 0 -}} + +{{/* 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 SVGs if it's the first time */}} +{{- if not ($.Page.Scratch.Get "noticecount") -}} +
+ + + + + + + + + + + + + + + + + +
+{{- end -}} + +{{- $.Page.Scratch.Add "noticecount" 1 -}} +
+

+ + + + {{- $noticeType | title -}} +

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

{{ $raw }}

+ {{ end -}} +
diff --git a/static/src/scss/_notice.scss b/static/src/scss/_notice.scss new file mode 100644 index 0000000..87c2a87 --- /dev/null +++ b/static/src/scss/_notice.scss @@ -0,0 +1,69 @@ +$notice-root: #FFF; +$notice-root-bg: #E7F2FA; +$notice-title: #FFF; +$notice-title-bg: #6AB0DE; + +$notice-warning-title: rgba(130, 49, 47, 0.9); +$notice-warning: #341312; +$notice-info-title: #906B4B; +$notice-info: #392A1E; +$notice-note-title: #3F6985; +$notice-note: #192A35; +$notice-tip-title: rgba(46, 92, 46, 0.8); +$notice-tip: #122412; + +.notice { + padding: 18px; + line-height: 24px; + margin-bottom: 24px; + border-radius: 4px; + color: $notice-root; + background: $notice-root-bg; + + p:last-child { + margin-bottom: 0; + } +} + +.notice.warning { + background: $notice-warning; + .notice-title {background: $notice-warning-title;} +} +.notice.info { + background: $notice-info; + .notice-title {background: $notice-info-title;} +} +.notice.note { + background: $notice-note; + .notice-title {background: $notice-note-title;} +} +.notice.tip { + background: $notice-tip; + .notice-title{background: $notice-tip-title;} +} + +.notice-title{ + margin: -18px -18px 12px; + padding: 4px 18px; + border-radius: 4px 4px 0 0; + font-weight: 700; + color: $notice-title; + background: $notice-title-bg; +} + +.icon-notice{ + display: inline-flex; + align-self: center; + margin-right: 8px; + + img, svg { + height: 1em; + width: 1em; + fill: currentColor; + } +} + +.icon-notice img, .icon-notice.baseline svg{ + top: 0.125em; + position: relative; +} diff --git a/static/src/scss/style.scss b/static/src/scss/style.scss index 8d76015..4c337ef 100644 --- a/static/src/scss/style.scss +++ b/static/src/scss/style.scss @@ -11,3 +11,4 @@ @import "anchors"; @import "code"; @import "code_copy"; +@import "notice"; diff --git a/themes/hugo-notice b/themes/hugo-notice deleted file mode 160000 index 2facc5d..0000000 --- a/themes/hugo-notice +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2facc5d4d60dcda57a3f3bd10591937b7e6ae84e