Skip to content

Commit

Permalink
fix: file path for 404 page
Browse files Browse the repository at this point in the history
  • Loading branch information
macrat committed Jan 16, 2024
1 parent 7212377 commit 31d92e0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
42 changes: 42 additions & 0 deletions builder/errorpages.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package main

import (
"github.com/macrat/blanktar/builder/fs"
)

type ErrorGenerator struct {
Template *TemplateLoader
}

func (e ErrorGenerator) Generate(dst fs.Writable, as ArtifactList, conf Config) (ArtifactList, error) {
tmpl, err := e.Template.Load("error.html")
if err != nil {
return nil, err
}

assets := ArtifactList{
Asset{
name: "/404.html",
},
}

if _, err := fs.Stat(dst, "/404.html"); err == nil {
return assets, nil
}

w, err := CreateOutput(dst, "/404.html", "text/html")
if err != nil {
return nil, err
}
defer w.Close()

err = tmpl.Execute(w, map[string]interface{}{
"Title": "404",
"Description": "Not Found",
})
if err != nil {
return nil, err
}

return assets, nil
}
1 change: 1 addition & 0 deletions builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ func main() {
Generator: GeneratorSet{
IndexGenerator{template},
PhotoGenerator{template},
ErrorGenerator{template},
},
}

Expand Down
6 changes: 0 additions & 6 deletions pages/404.md

This file was deleted.

0 comments on commit 31d92e0

Please sign in to comment.