diff --git a/cmd/anna/anna.go b/cmd/anna/anna.go index 1a03006..1e2e92c 100644 --- a/cmd/anna/anna.go +++ b/cmd/anna/anna.go @@ -55,6 +55,7 @@ func (cmd *Cmd) VanillaRender() { e.GenerateSitemap(helpers.SiteDataPath + "rendered/layout/sitemap.xml") e.GenerateFeed() + p.ParseJsonMerged() sort.Slice(e.Posts, func(i, j int) bool { return e.Posts[i].Frontmatter.Date > e.Posts[j].Frontmatter.Date diff --git a/main.go b/main.go index 0e78cd7..e8462a3 100644 --- a/main.go +++ b/main.go @@ -69,7 +69,7 @@ func main() { annaCmd.VanillaRender() }, } - go anna.CreateIndex() + // go anna.CreateIndex() rootCmd.Flags().BoolVarP(&serve, "serve", "s", false, "serve the rendered content") rootCmd.Flags().StringVarP(&addr, "addr", "a", "8000", "ip address to serve rendered content to") diff --git a/pkg/parser/parser.go b/pkg/parser/parser.go index d8fc6e2..25a8a3a 100644 --- a/pkg/parser/parser.go +++ b/pkg/parser/parser.go @@ -2,6 +2,7 @@ package parser import ( "bytes" + "encoding/json" "regexp" "html/template" @@ -53,6 +54,13 @@ type TemplateData struct { SpecificTagTemplates []TemplateData } +type JsonTemplate struct { + CompleteURL template.URL + FilenameWithoutExtension string + Frontmatter Frontmatter + Tags []string +} + type Date int64 type Parser struct { @@ -257,3 +265,39 @@ func (p *Parser) ParseLayoutFiles() *template.Template { return templ } + +func (p *Parser) ParseJsonMerged() { + // create a json file + jsonFile, err := os.Create(helpers.SiteDataPath + "/static/scripts/merged.json") + if err != nil { + jsonFile.Close() + p.ErrorLogger.Fatal(err) + } + + // copy data from p.Templates to new JsonTemplate + jsonMergedTemplate := make(map[template.URL]JsonTemplate) + for key, value := range p.Templates { + // copy the values + jsonMergedTemplate[key] = JsonTemplate{ + CompleteURL: value.CompleteURL, + FilenameWithoutExtension: value.FilenameWithoutExtension, + Frontmatter: value.Frontmatter, + Tags: value.Tags, + } + } + + // marshal the new JsonTemplate + jsonMerged, err := json.Marshal(jsonMergedTemplate) + if err != nil { + jsonFile.Close() + p.ErrorLogger.Fatal(err) + } + + // write the new JsonTemplate to the json file + _, err = jsonFile.Write(jsonMerged) + if err != nil { + jsonFile.Close() + p.ErrorLogger.Fatal(err) + } + jsonFile.Close() +} diff --git a/site/layout/page.html b/site/layout/page.html index 076cba3..4a29a8d 100644 --- a/site/layout/page.html +++ b/site/layout/page.html @@ -11,27 +11,6 @@
- - - - - - - - - {{end}} {{.Body}} diff --git a/site/layout/partials/header.html b/site/layout/partials/header.html index 47ddf18..2747df7 100644 --- a/site/layout/partials/header.html +++ b/site/layout/partials/header.html @@ -8,4 +8,66 @@ {{end}} {{end}} + + + + {{end}} diff --git a/site/static/scripts/merged.json b/site/static/scripts/merged.json new file mode 100644 index 0000000..74bf186 --- /dev/null +++ b/site/static/scripts/merged.json @@ -0,0 +1 @@ +{"docs.md":{"CompleteURL":"docs.html","FilenameWithoutExtension":"docs","Frontmatter":{"Title":"Anna Documentation","Date":"","Draft":false,"JSFiles":null,"Type":"","Description":"","PreviewImage":"","Tags":null},"Tags":null},"index copy.md":{"CompleteURL":"index copy.html","FilenameWithoutExtension":"index copy","Frontmatter":{"Title":"Home","Date":"2024-02-24","Draft":false,"JSFiles":null,"Type":"","Description":"homepage for our ssg","PreviewImage":"/static/plane.jpg","Tags":null},"Tags":null},"index.md":{"CompleteURL":"index.html","FilenameWithoutExtension":"index","Frontmatter":{"Title":"Home","Date":"2024-02-24","Draft":false,"JSFiles":null,"Type":"","Description":"homepage for our ssg","PreviewImage":"/static/plane.jpg","Tags":null},"Tags":null},"lang_test copy.md":{"CompleteURL":"posts/lang_test copy.html","FilenameWithoutExtension":"lang_test copy","Frontmatter":{"Title":"Language Codeblock Test","Date":"2024-02-23","Draft":false,"JSFiles":null,"Type":"post","Description":"","PreviewImage":"","Tags":["rust","C"]},"Tags":null},"lang_test.md":{"CompleteURL":"posts/lang_test.html","FilenameWithoutExtension":"lang_test","Frontmatter":{"Title":"Language Codeblock Test","Date":"2024-02-23","Draft":false,"JSFiles":null,"Type":"post","Description":"","PreviewImage":"","Tags":["rust","C"]},"Tags":null},"test_0.md":{"CompleteURL":"posts/test_0.html","FilenameWithoutExtension":"test_0","Frontmatter":{"Title":"Chronological Test 2","Date":"2023-01-02","Draft":false,"JSFiles":null,"Type":"post","Description":"This is a test description","PreviewImage":"","Tags":["test-post"]},"Tags":null},"week-1.md":{"CompleteURL":"posts/week-1.html","FilenameWithoutExtension":"week-1","Frontmatter":{"Title":"Week-1 Progress","Date":"2024-03-25","Draft":false,"JSFiles":null,"Type":"post","Description":"","PreviewImage":"","Tags":["progress"]},"Tags":null},"week-2.md":{"CompleteURL":"posts/week-2.html","FilenameWithoutExtension":"week-2","Frontmatter":{"Title":"Week-2 Progress","Date":"2024-04-01","Draft":false,"JSFiles":null,"Type":"post","Description":"","PreviewImage":"","Tags":["progress"]},"Tags":null}} \ No newline at end of file diff --git a/site/static/scripts/search.go b/site/static/scripts/search.go.temp similarity index 100% rename from site/static/scripts/search.go rename to site/static/scripts/search.go.temp diff --git a/site/static/style.css b/site/static/style.css index 5b39578..50e9f77 100644 --- a/site/static/style.css +++ b/site/static/style.css @@ -73,6 +73,28 @@ nav { } } +#searchSiteInput { + background: #11111a; + color: white; + border: 1px solid #5990ac; + border-radius: 5px; + margin-left: 1rem; + padding: 0.5rem; + ::placeholder { + color: white; + } + &:focus { + outline: none; + } + $:active { + outline: none; + } +} + +#result { + margin-left: 1rem; +} + a { color:#5990ac; text-decoration: none; @@ -177,7 +199,7 @@ iframe { flex-direction: row; align-items: center; flex-wrap: wrap; - + & > a { font-size: 1.2rem; background-color: #1e1e1e; @@ -186,7 +208,7 @@ iframe { margin: .3rem; } - + } .tag-placeholder { @@ -363,7 +385,7 @@ blockquote { nav { font-size: 1.05rem; } - + iframe { width: auto; height: auto; @@ -388,7 +410,7 @@ blockquote { margin-top: 2rem; margin-bottom: 2rem; } - + .body { & > a, @@ -407,7 +429,7 @@ blockquote { & > p, & > .post-card-div > p { font-size: .9rem; - } + } & > h3 { font-size: 1.3rem; @@ -423,5 +445,3 @@ blockquote { height: auto; } } - -