From 67152c7079955025ca3df5608336ff82a63535e4 Mon Sep 17 00:00:00 2001 From: Jan-Lukas Else Date: Thu, 9 Sep 2021 08:26:35 +0200 Subject: [PATCH] Add option to add announcement to blog header --- config.go | 5 +++++ example-config.yml | 5 ++++- original-assets/styles/styles.scss | 30 +++++++++++++++++++++-------- templates/assets/css/styles.css | 31 +++++++++++++++++++----------- templates/header.gohtml | 5 +++++ 5 files changed, 56 insertions(+), 20 deletions(-) diff --git a/config.go b/config.go index bfcc024..2a98e3c 100644 --- a/config.go +++ b/config.go @@ -76,6 +76,7 @@ type configBlog struct { Comments *configComments `mapstructure:"comments"` Map *configGeoMap `mapstructure:"map"` Contact *configContact `mapstructure:"contact"` + Announcement *configAnnouncement `mapstructure:"announcement"` } type configSection struct { @@ -170,6 +171,10 @@ type configContact struct { EmailTo string `mapstructure:"emailTo"` } +type configAnnouncement struct { + Text string `mapstructure:"text"` +} + type configUser struct { Nick string `mapstructure:"nick"` Name string `mapstructure:"name"` diff --git a/example-config.yml b/example-config.yml index 570f9c5..73d53fd 100644 --- a/example-config.yml +++ b/example-config.yml @@ -235,4 +235,7 @@ blogs: smtpUser: mail@example.com # SMTP user smtpPassword: secret # SMTP password emailFrom: blog@example.com # Email sender - emailTo: mail@example.com # Email recipient \ No newline at end of file + emailTo: mail@example.com # Email recipient + # Announcement + announcement: + text: This is an **announcement**! # Can be markdown with links etc. \ No newline at end of file diff --git a/original-assets/styles/styles.scss b/original-assets/styles/styles.scss index 3816a4a..91edc22 100644 --- a/original-assets/styles/styles.scss +++ b/original-assets/styles/styles.scss @@ -137,13 +137,7 @@ pre { mark, :not(pre) > code { font-size: 1rem; - // Invert - @include color(color, background); - @include color(background, primary); - &::selection { - @include color(color, primary); - @include color(background, background); - } + @extend .invert; } code { @@ -234,6 +228,15 @@ details summary { transition: transform 2s ease; } +.invert { + @include color(color, background); + @include color(background, primary); + &::selection { + @include color(color, primary); + @include color(background, background); + } +} + #map { height: 400px; } @@ -249,6 +252,16 @@ details summary { } } +#announcement { + @extend .invert; + padding: 5px; + text-align: center; + margin-bottom: 10px; + * { + @extend .invert; + } +} + // Print @media print { html { @@ -266,7 +279,8 @@ details summary { #related, #interactions, #posteditactions, - #tor { + #tor, + #announcement { display: none; } diff --git a/templates/assets/css/styles.css b/templates/assets/css/styles.css index b70df93..1cf1ec5 100644 --- a/templates/assets/css/styles.css +++ b/templates/assets/css/styles.css @@ -94,16 +94,6 @@ pre { mark, :not(pre) > code { font-size: 1rem; - color: #fff; - color: var(--background, #fff); - background: #000; - background: var(--primary, #000); -} -mark::selection, :not(pre) > code::selection { - color: #000; - color: var(--primary, #000); - background: #fff; - background: var(--background, #fff); } code { @@ -191,6 +181,19 @@ details summary > *:first-child { transition: transform 2s ease; } +.invert, #announcement *, #announcement, mark, :not(pre) > code { + color: #fff; + color: var(--background, #fff); + background: #000; + background: var(--primary, #000); +} +.invert::selection, #announcement ::selection, #announcement::selection, mark::selection, :not(pre) > code::selection { + color: #000; + color: var(--primary, #000); + background: #fff; + background: var(--background, #fff); +} + #map { height: 400px; } @@ -204,6 +207,11 @@ details summary > *:first-child { text-align: center; } +#announcement { + padding: 5px; + text-align: center; + margin-bottom: 10px; +} @media print { html { --background: #fff; @@ -222,7 +230,8 @@ details summary > *:first-child { #related, #interactions, #posteditactions, -#tor { +#tor, +#announcement { display: none; } diff --git a/templates/header.gohtml b/templates/header.gohtml index 28587e2..a95b46a 100644 --- a/templates/header.gohtml +++ b/templates/header.gohtml @@ -1,4 +1,9 @@ {{ define "header" }} + {{ with .Blog.Announcement }}{{ with .Text }} +
+ {{ md . }} +
+ {{ end }}{{ end }}

{{ mdtitle .Blog.Title }}

{{ with .Blog.Description }}

{{ . }}

{{ end }}