Add site description to home page

This commit is contained in:
ChaoticByte 2024-08-29 13:29:39 +02:00
parent b86b1688ea
commit 1db5336f35
No known key found for this signature in database
6 changed files with 24 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 KiB

After

Width:  |  Height:  |  Size: 200 KiB

Before After
Before After

14
main.go
View file

@ -16,10 +16,11 @@ var appTemplate *template.Template = template.New("app")
var db Database
type TemplateData struct {
TOC []string
Entry string
Title string
SiteDescription string
TOC []string
EntryTitle string
Entry string
Footer []template.HTML
}
@ -42,7 +43,14 @@ func handleApplication(w http.ResponseWriter, req *http.Request) {
}
err = appTemplate.ExecuteTemplate(
w, "app",
TemplateData{TOC: db.Keys, Entry: entry, Title: MainTitle, EntryTitle: entryName, Footer: FooterContent})
TemplateData{
TOC: db.Keys,
Entry: entry,
Title: MainTitle,
EntryTitle: entryName,
Footer: FooterContent,
SiteDescription: SiteDescription,
})
if err != nil { logger.Println(err) }
}

View file

@ -19,7 +19,10 @@
</div>
{{- else -}}
<div class="home-main">
<div class="about">
<h1>{{ .Title }}</h1>
{{ if .SiteDescription }}<div class="description">{{ .SiteDescription }}</div>{{ end }}
</div>
<input type="text" id="search-box" placeholder="search">
<div id="search-results" class="hidden"></div>
<div class="toc" id="toc">

View file

@ -62,9 +62,15 @@ footer, footer * {
box-sizing: border-box;
gap: 1rem;
}
.home-main > h1 {
.about {
margin-bottom: 2rem;
}
.about > h1 {
font-size: 1.6rem;
}
.description {
white-space: pre-line;
}
.home-main, .toc, #search-results {
display: flex;
flex-direction: column;

View file

@ -14,6 +14,8 @@ const StaticDirectory = "./public/static"
var ContentLanguage = language.English
const MainTitle = "Encyclopedia"
var SiteDescription = `A very simple and clean reader/browser?
for plaintext... documentation? wiki? chapters of a book? whatever.`
var FooterContent = []template.HTML{
template.HTML("powered by <a href='https://github.com/ChaoticByte/plaintext-encyclopedia' target='_blank' rel='noopener noreferrer'>plaintext-encyclopedia</a>"),
}