Server static files

This commit is contained in:
Maximilian Friedersdorff 2025-01-28 22:08:01 +00:00
parent 2ba0a0024e
commit 73a1c8bc02
7 changed files with 52 additions and 14 deletions

View file

@ -4,14 +4,20 @@ import (
"log"
"os"
"github.com/pelletier/go-toml"
"github.com/pelletier/go-toml/v2"
)
type Config struct {
Extension string
NotesDir string
TemplatesDir string
BaseTemplate string
Extension string
NotesDir string
Templates struct {
Dir string
Base string
}
Static struct {
Dir string
Root string
}
}
var Conf Config

View file

@ -13,8 +13,8 @@ type Ctx map[string]any
func RenderTemplate(w http.ResponseWriter, tmpl string, context any) error {
files := []string{
filepath.Join(conf.Conf.TemplatesDir, conf.Conf.BaseTemplate),
filepath.Join(conf.Conf.TemplatesDir, tmpl),
filepath.Join(conf.Conf.Templates.Dir, conf.Conf.Templates.Base),
filepath.Join(conf.Conf.Templates.Dir, tmpl),
}
for _, f := range files {