From fd618a312180bf3a53f20e71e7c0781bcc63eb9b Mon Sep 17 00:00:00 2001 From: Anirudh Sudhir Date: Thu, 11 Apr 2024 20:45:30 +0530 Subject: [PATCH] chore: switch layouts to html --- cmd/anna/anna.go | 4 +- pkg/engine/anna_engine.go | 1 + pkg/engine/anna_engine_test.go | 2 +- pkg/engine/engine.go | 1 + pkg/engine/engine_integration_test.go | 2 +- pkg/engine/engine_test.go | 2 +- pkg/engine/user_engine_test.go | 2 +- pkg/parser/parser.go | 4 +- site/layout/{page.layout => page.html} | 0 .../partials/{footer.layout => footer.html} | 0 .../partials/{head.layout => head.html} | 0 .../partials/{header.layout => header.html} | 0 .../partials/{search.layout => search.html} | 0 site/layout/{posts.layout => posts.html} | 0 .../{tag-subpage.layout => tag-subpage.html} | 0 site/layout/{tags.layout => tags.html} | 0 site/static/index.json | 101 +----------------- test/engine/json_index_test/want_index.json | 2 +- ...ts_template.layout => posts_template.html} | 0 ...plate_input.layout => template_input.html} | 0 ...late.layout => tags_subpage_template.html} | 0 ...ags_template.layout => tags_template.html} | 0 ...plate_input.layout => template_input.html} | 0 23 files changed, 12 insertions(+), 109 deletions(-) rename site/layout/{page.layout => page.html} (100%) rename site/layout/partials/{footer.layout => footer.html} (100%) rename site/layout/partials/{head.layout => head.html} (100%) rename site/layout/partials/{header.layout => header.html} (100%) rename site/layout/partials/{search.layout => search.html} (100%) rename site/layout/{posts.layout => posts.html} (100%) rename site/layout/{tag-subpage.layout => tag-subpage.html} (100%) rename site/layout/{tags.layout => tags.html} (100%) rename test/engine/render_engine_generated/{posts_template.layout => posts_template.html} (100%) rename test/engine/render_page/{template_input.layout => template_input.html} (100%) rename test/engine/render_tags/{tags_subpage_template.layout => tags_subpage_template.html} (100%) rename test/engine/render_tags/{tags_template.layout => tags_template.html} (100%) rename test/engine/render_user_defined/{template_input.layout => template_input.html} (100%) diff --git a/cmd/anna/anna.go b/cmd/anna/anna.go index ecc118d..95a5d9c 100644 --- a/cmd/anna/anna.go +++ b/cmd/anna/anna.go @@ -62,12 +62,12 @@ func (cmd *Cmd) VanillaRender() { return e.DeepDataMerge.Posts[i].Frontmatter.Date > e.DeepDataMerge.Posts[j].Frontmatter.Date }) - templ, err := template.ParseGlob(helpers.SiteDataPath + "layout/*.layout") + templ, err := template.ParseGlob(helpers.SiteDataPath + "layout/*.html") if err != nil { e.ErrorLogger.Fatalf("%v", err) } - templ, err = templ.ParseGlob(helpers.SiteDataPath + "layout/partials/*.layout") + templ, err = templ.ParseGlob(helpers.SiteDataPath + "layout/partials/*.html") if err != nil { e.ErrorLogger.Fatalf("%v", err) } diff --git a/pkg/engine/anna_engine.go b/pkg/engine/anna_engine.go index c0b0aa1..2101d37 100644 --- a/pkg/engine/anna_engine.go +++ b/pkg/engine/anna_engine.go @@ -118,6 +118,7 @@ func (e *Engine) GenerateJSONIndex(outFilePath string) { jsonIndexTemplate[templateURL] = JSONIndexTemplate{ CompleteURL: templateData.CompleteURL, Frontmatter: templateData.Frontmatter, + Tags: templateData.Frontmatter.Tags, } } diff --git a/pkg/engine/anna_engine_test.go b/pkg/engine/anna_engine_test.go index 39545ec..4d1636b 100644 --- a/pkg/engine/anna_engine_test.go +++ b/pkg/engine/anna_engine_test.go @@ -57,7 +57,7 @@ func TestRenderTags(t *testing.T) { }, } - templ, err := template.ParseFiles(TestDirPath+"render_tags/tags_template.layout", TestDirPath+"render_tags/tags_subpage_template.layout") + templ, err := template.ParseFiles(TestDirPath+"render_tags/tags_template.html", TestDirPath+"render_tags/tags_subpage_template.html") if err != nil { t.Errorf("%v", err) } diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index e90e3e4..4bbcfda 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -50,6 +50,7 @@ type PageData struct { type JSONIndexTemplate struct { CompleteURL template.URL Frontmatter parser.Frontmatter + Tags []string } /* diff --git a/pkg/engine/engine_integration_test.go b/pkg/engine/engine_integration_test.go index 2271822..a1e7b2a 100644 --- a/pkg/engine/engine_integration_test.go +++ b/pkg/engine/engine_integration_test.go @@ -35,7 +35,7 @@ func TestRenderUserDefinedPages(t *testing.T) { t.Run("render a set of user defined pages", func(t *testing.T) { - templ, err := template.ParseFiles(TestDirPath + "render_user_defined/template_input.layout") + templ, err := template.ParseFiles(TestDirPath + "render_user_defined/template_input.html") if err != nil { t.Errorf("%v", err) } diff --git a/pkg/engine/engine_test.go b/pkg/engine/engine_test.go index 7c44c17..682abfd 100644 --- a/pkg/engine/engine_test.go +++ b/pkg/engine/engine_test.go @@ -44,7 +44,7 @@ func TestRenderPage(t *testing.T) { }, } - templ, err := template.ParseFiles(TestDirPath + "render_page/template_input.layout") + templ, err := template.ParseFiles(TestDirPath + "render_page/template_input.html") if err != nil { t.Errorf("%v", err) } diff --git a/pkg/engine/user_engine_test.go b/pkg/engine/user_engine_test.go index 1ac3670..9aa5e40 100644 --- a/pkg/engine/user_engine_test.go +++ b/pkg/engine/user_engine_test.go @@ -53,7 +53,7 @@ func TestRenderEngineGeneratedFiles(t *testing.T) { } t.Run("test rendering of post.html", func(t *testing.T) { - templ, err := template.ParseFiles(TestDirPath + "render_engine_generated/posts_template.layout") + templ, err := template.ParseFiles(TestDirPath + "render_engine_generated/posts_template.html") if err != nil { t.Errorf("%v", err) } diff --git a/pkg/parser/parser.go b/pkg/parser/parser.go index e574afb..736f603 100644 --- a/pkg/parser/parser.go +++ b/pkg/parser/parser.go @@ -250,13 +250,13 @@ func (p *Parser) ParseRobots(inFilePath string, outFilePath string) { func (p *Parser) ParseLayoutFiles() *template.Template { // Parsing all files in the layout/ dir which match the "*.html" pattern - templ, err := template.ParseGlob(helpers.SiteDataPath + "layout/*.layout") + templ, err := template.ParseGlob(helpers.SiteDataPath + "layout/*.html") if err != nil { p.ErrorLogger.Fatal(err) } // Parsing all files in the partials/ dir which match the "*.html" pattern - templ, err = templ.ParseGlob(helpers.SiteDataPath + "layout/partials/*.layout") + templ, err = templ.ParseGlob(helpers.SiteDataPath + "layout/partials/*.html") if err != nil { p.ErrorLogger.Fatal(err) } diff --git a/site/layout/page.layout b/site/layout/page.html similarity index 100% rename from site/layout/page.layout rename to site/layout/page.html diff --git a/site/layout/partials/footer.layout b/site/layout/partials/footer.html similarity index 100% rename from site/layout/partials/footer.layout rename to site/layout/partials/footer.html diff --git a/site/layout/partials/head.layout b/site/layout/partials/head.html similarity index 100% rename from site/layout/partials/head.layout rename to site/layout/partials/head.html diff --git a/site/layout/partials/header.layout b/site/layout/partials/header.html similarity index 100% rename from site/layout/partials/header.layout rename to site/layout/partials/header.html diff --git a/site/layout/partials/search.layout b/site/layout/partials/search.html similarity index 100% rename from site/layout/partials/search.layout rename to site/layout/partials/search.html diff --git a/site/layout/posts.layout b/site/layout/posts.html similarity index 100% rename from site/layout/posts.layout rename to site/layout/posts.html diff --git a/site/layout/tag-subpage.layout b/site/layout/tag-subpage.html similarity index 100% rename from site/layout/tag-subpage.layout rename to site/layout/tag-subpage.html diff --git a/site/layout/tags.layout b/site/layout/tags.html similarity index 100% rename from site/layout/tags.layout rename to site/layout/tags.html diff --git a/site/static/index.json b/site/static/index.json index 61c8828..8dfa96c 100644 --- a/site/static/index.json +++ b/site/static/index.json @@ -1,100 +1 @@ -{ - "docs.html": { - "CompleteURL": "docs.html", - "Frontmatter": { - "Title": "Anna Documentation", - "Date": "2024-04-10", - "Draft": false, - "JSFiles": null, - "Type": "", - "Description": "", - "PreviewImage": "", - "Tags": null, - "Authors": null - } - }, - "index.html": { - "CompleteURL": "index.html", - "Frontmatter": { - "Title": "Home", - "Date": "2024-02-24", - "Draft": false, - "JSFiles": null, - "Type": "", - "Description": "homepage for our ssg", - "PreviewImage": "/static/plane.jpg", - "Tags": null, - "Authors": null - } - }, - "posts/bench.html": { - "CompleteURL": "posts/bench.html", - "Frontmatter": { - "Title": "benchmark", - "Date": "2024-01-01", - "Draft": false, - "JSFiles": null, - "Type": "post", - "Description": "", - "PreviewImage": "", - "Tags": ["test-post"], - "Authors": null - } - }, - "posts/building_anna.html": { - "CompleteURL": "posts/building_anna.html", - "Frontmatter": { - "Title": "Building anna", - "Date": "2024-04-04", - "Draft": false, - "JSFiles": null, - "Type": "post", - "Description": "This page contains a post about anna, a static site generator written in Go. This team project was built as part of AIEP 2024", - "PreviewImage": "", - "Tags": ["acm", "hsp", "go", "tech", "talk", "aiep"], - "Authors": ["Adhesh", "Aditya", "Nathan", "Anirudh"] - } - }, - "posts/week-1.html": { - "CompleteURL": "posts/week-1.html", - "Frontmatter": { - "Title": "Week-1 Progress", - "Date": "2024-03-18", - "Draft": false, - "JSFiles": null, - "Type": "post", - "Description": "", - "PreviewImage": "", - "Tags": ["progress"], - "Authors": ["Adhesh", "Aditya", "Anirudh", "Nathan"] - } - }, - "posts/week-2.html": { - "CompleteURL": "posts/week-2.html", - "Frontmatter": { - "Title": "Week-2 Progress", - "Date": "2024-03-25", - "Draft": false, - "JSFiles": null, - "Type": "post", - "Description": "", - "PreviewImage": "", - "Tags": ["progress"], - "Authors": ["Adhesh", "Aditya", "Anirudh", "Nathan"] - } - }, - "posts/week-3.html": { - "CompleteURL": "posts/week-3.html", - "Frontmatter": { - "Title": "Week-3 Progress", - "Date": "2024-04-01", - "Draft": false, - "JSFiles": null, - "Type": "post", - "Description": "", - "PreviewImage": "", - "Tags": ["progress"], - "Authors": ["Adhesh", "Aditya", "Anirudh", "Nathan"] - } - } -} +{"docs.html":{"CompleteURL":"docs.html","Frontmatter":{"Title":"Anna Documentation","Date":"2024-04-10","Draft":false,"JSFiles":null,"Type":"","Description":"","PreviewImage":"","Tags":null,"Authors":null},"Tags":null},"index.html":{"CompleteURL":"index.html","Frontmatter":{"Title":"Home","Date":"2024-02-24","Draft":false,"JSFiles":null,"Type":"","Description":"homepage for our ssg","PreviewImage":"/static/plane.jpg","Tags":null,"Authors":null},"Tags":null},"posts/bench.html":{"CompleteURL":"posts/bench.html","Frontmatter":{"Title":"benchmark","Date":"2024-01-01","Draft":false,"JSFiles":null,"Type":"post","Description":"","PreviewImage":"","Tags":["test-post"],"Authors":null},"Tags":["test-post"]},"posts/building_anna.html":{"CompleteURL":"posts/building_anna.html","Frontmatter":{"Title":"Building anna","Date":"2024-04-04","Draft":false,"JSFiles":null,"Type":"post","Description":"This page contains a post about anna, a static site generator written in Go. This team project was built as part of AIEP 2024","PreviewImage":"","Tags":["acm","hsp","go","tech","talk","aiep"],"Authors":["Adhesh","Aditya","Nathan","Anirudh"]},"Tags":["acm","hsp","go","tech","talk","aiep"]},"posts/week-1.html":{"CompleteURL":"posts/week-1.html","Frontmatter":{"Title":"Week-1 Progress","Date":"2024-03-18","Draft":false,"JSFiles":null,"Type":"post","Description":"","PreviewImage":"","Tags":["progress"],"Authors":["Adhesh","Aditya","Anirudh","Nathan"]},"Tags":["progress"]},"posts/week-2.html":{"CompleteURL":"posts/week-2.html","Frontmatter":{"Title":"Week-2 Progress","Date":"2024-03-25","Draft":false,"JSFiles":null,"Type":"post","Description":"","PreviewImage":"","Tags":["progress"],"Authors":["Adhesh","Aditya","Anirudh","Nathan"]},"Tags":["progress"]},"posts/week-3.html":{"CompleteURL":"posts/week-3.html","Frontmatter":{"Title":"Week-3 Progress","Date":"2024-04-01","Draft":false,"JSFiles":null,"Type":"post","Description":"","PreviewImage":"","Tags":["progress"],"Authors":["Adhesh","Aditya","Anirudh","Nathan"]},"Tags":["progress"]}} \ No newline at end of file diff --git a/test/engine/json_index_test/want_index.json b/test/engine/json_index_test/want_index.json index a6f6b45..317502d 100644 --- a/test/engine/json_index_test/want_index.json +++ b/test/engine/json_index_test/want_index.json @@ -1 +1 @@ -{"docs.md":{"CompleteURL":"docs.html","Frontmatter":{"Title":"Anna Documentation","Date":"","Draft":false,"JSFiles":null,"Type":"","Description":"","PreviewImage":"","Tags":null,"Authors":null}}} +{"docs.md":{"CompleteURL":"docs.html","Frontmatter":{"Title":"Anna Documentation","Date":"","Draft":false,"JSFiles":null,"Type":"","Description":"","PreviewImage":"","Tags":null,"Authors":null},"Tags":null}} \ No newline at end of file diff --git a/test/engine/render_engine_generated/posts_template.layout b/test/engine/render_engine_generated/posts_template.html similarity index 100% rename from test/engine/render_engine_generated/posts_template.layout rename to test/engine/render_engine_generated/posts_template.html diff --git a/test/engine/render_page/template_input.layout b/test/engine/render_page/template_input.html similarity index 100% rename from test/engine/render_page/template_input.layout rename to test/engine/render_page/template_input.html diff --git a/test/engine/render_tags/tags_subpage_template.layout b/test/engine/render_tags/tags_subpage_template.html similarity index 100% rename from test/engine/render_tags/tags_subpage_template.layout rename to test/engine/render_tags/tags_subpage_template.html diff --git a/test/engine/render_tags/tags_template.layout b/test/engine/render_tags/tags_template.html similarity index 100% rename from test/engine/render_tags/tags_template.layout rename to test/engine/render_tags/tags_template.html diff --git a/test/engine/render_user_defined/template_input.layout b/test/engine/render_user_defined/template_input.html similarity index 100% rename from test/engine/render_user_defined/template_input.layout rename to test/engine/render_user_defined/template_input.html