refactor: move document head includes out of via configuration into their own append funcs; update examples

This commit is contained in:
Joao Goncalves
2025-11-09 03:17:03 -01:00
parent 5c80a934e9
commit 9f9e4eb568
7 changed files with 72 additions and 90 deletions

View File

@@ -8,8 +8,8 @@ import (
"github.com/go-via/via/h"
)
// In this example we create a Via application with a plugin that adds PicoCSS. The plugin
// is handed to Via in the app Configuration.
// Example of a Via application with a plugin that adds PicoCSS. The plugin
// is handed to Via in the Configuration.
//go:embed pico.yellow.min.css
var picoCSSFile []byte
@@ -41,9 +41,5 @@ func PicoCSSPlugin(v *via.V) {
w.Header().Set("Content-Type", "text/css")
_, _ = w.Write(picoCSSFile)
})
v.Config(via.Options{
DocumentHeadIncludes: []h.H{
h.Link(h.Rel("stylesheet"), h.Href("/_plugins/picocss/assets/style.css")),
},
})
v.AppendToHead(h.Link(h.Rel("stylesheet"), h.Href("/_plugins/picocss/assets/style.css")))
}