Add option to add announcement to blog header

This commit is contained in:
Jan-Lukas Else 2021-09-09 08:26:35 +02:00
parent 79f807e01a
commit 67152c7079
5 changed files with 56 additions and 20 deletions

View File

@ -76,6 +76,7 @@ type configBlog struct {
Comments *configComments `mapstructure:"comments"` Comments *configComments `mapstructure:"comments"`
Map *configGeoMap `mapstructure:"map"` Map *configGeoMap `mapstructure:"map"`
Contact *configContact `mapstructure:"contact"` Contact *configContact `mapstructure:"contact"`
Announcement *configAnnouncement `mapstructure:"announcement"`
} }
type configSection struct { type configSection struct {
@ -170,6 +171,10 @@ type configContact struct {
EmailTo string `mapstructure:"emailTo"` EmailTo string `mapstructure:"emailTo"`
} }
type configAnnouncement struct {
Text string `mapstructure:"text"`
}
type configUser struct { type configUser struct {
Nick string `mapstructure:"nick"` Nick string `mapstructure:"nick"`
Name string `mapstructure:"name"` Name string `mapstructure:"name"`

View File

@ -235,4 +235,7 @@ blogs:
smtpUser: mail@example.com # SMTP user smtpUser: mail@example.com # SMTP user
smtpPassword: secret # SMTP password smtpPassword: secret # SMTP password
emailFrom: blog@example.com # Email sender emailFrom: blog@example.com # Email sender
emailTo: mail@example.com # Email recipient emailTo: mail@example.com # Email recipient
# Announcement
announcement:
text: This is an **announcement**! # Can be markdown with links etc.

View File

@ -137,13 +137,7 @@ pre {
mark, :not(pre) > code { mark, :not(pre) > code {
font-size: 1rem; font-size: 1rem;
// Invert @extend .invert;
@include color(color, background);
@include color(background, primary);
&::selection {
@include color(color, primary);
@include color(background, background);
}
} }
code { code {
@ -234,6 +228,15 @@ details summary {
transition: transform 2s ease; transition: transform 2s ease;
} }
.invert {
@include color(color, background);
@include color(background, primary);
&::selection {
@include color(color, primary);
@include color(background, background);
}
}
#map { #map {
height: 400px; height: 400px;
} }
@ -249,6 +252,16 @@ details summary {
} }
} }
#announcement {
@extend .invert;
padding: 5px;
text-align: center;
margin-bottom: 10px;
* {
@extend .invert;
}
}
// Print // Print
@media print { @media print {
html { html {
@ -266,7 +279,8 @@ details summary {
#related, #related,
#interactions, #interactions,
#posteditactions, #posteditactions,
#tor { #tor,
#announcement {
display: none; display: none;
} }

View File

@ -94,16 +94,6 @@ pre {
mark, :not(pre) > code { mark, :not(pre) > code {
font-size: 1rem; 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 { code {
@ -191,6 +181,19 @@ details summary > *:first-child {
transition: transform 2s ease; 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 { #map {
height: 400px; height: 400px;
} }
@ -204,6 +207,11 @@ details summary > *:first-child {
text-align: center; text-align: center;
} }
#announcement {
padding: 5px;
text-align: center;
margin-bottom: 10px;
}
@media print { @media print {
html { html {
--background: #fff; --background: #fff;
@ -222,7 +230,8 @@ details summary > *:first-child {
#related, #related,
#interactions, #interactions,
#posteditactions, #posteditactions,
#tor { #tor,
#announcement {
display: none; display: none;
} }

View File

@ -1,4 +1,9 @@
{{ define "header" }} {{ define "header" }}
{{ with .Blog.Announcement }}{{ with .Text }}
<div id="announcement" data-nosnippet>
{{ md . }}
</div>
{{ end }}{{ end }}
<header> <header>
<h1><a href="{{ .Blog.RelativePath "/" }}" rel="home" title="{{ mdtitle .Blog.Title }}" translate="no">{{ mdtitle .Blog.Title }}</a></h1> <h1><a href="{{ .Blog.RelativePath "/" }}" rel="home" title="{{ mdtitle .Blog.Title }}" translate="no">{{ mdtitle .Blog.Title }}</a></h1>
{{ with .Blog.Description }}<p><i>{{ . }}</i></p>{{ end }} {{ with .Blog.Description }}<p><i>{{ . }}</i></p>{{ end }}