Skip to content

Commit

Permalink
chore: switch layouts to html
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudhsudhir committed Apr 11, 2024
1 parent 4471a9a commit fd618a3
Show file tree
Hide file tree
Showing 23 changed files with 12 additions and 109 deletions.
4 changes: 2 additions & 2 deletions cmd/anna/anna.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/engine/anna_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func (e *Engine) GenerateJSONIndex(outFilePath string) {
jsonIndexTemplate[templateURL] = JSONIndexTemplate{
CompleteURL: templateData.CompleteURL,
Frontmatter: templateData.Frontmatter,
Tags: templateData.Frontmatter.Tags,
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/engine/anna_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type PageData struct {
type JSONIndexTemplate struct {
CompleteURL template.URL
Frontmatter parser.Frontmatter
Tags []string
}

/*
Expand Down
2 changes: 1 addition & 1 deletion pkg/engine/engine_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/engine/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/engine/user_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
101 changes: 1 addition & 100 deletions site/static/index.json
Original file line number Diff line number Diff line change
@@ -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"]}}
2 changes: 1 addition & 1 deletion test/engine/json_index_test/want_index.json
Original file line number Diff line number Diff line change
@@ -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}}
File renamed without changes.
File renamed without changes.

0 comments on commit fd618a3

Please sign in to comment.