add versioning
This commit is contained in:
parent
90117e7b0f
commit
d063a8da63
2 changed files with 28 additions and 2 deletions
|
|
@ -63,6 +63,18 @@ func Meta(name string, content string) Ren {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func LinkWithVersion(href string, rel string, version string) Ren {
|
||||||
|
attributeMap := AttributeMap{
|
||||||
|
"href": href + "?v=" + version,
|
||||||
|
"rel": rel,
|
||||||
|
}
|
||||||
|
return &Element{
|
||||||
|
tag: "link",
|
||||||
|
attributes: attributeMap.ToMap(),
|
||||||
|
children: make([]Ren, 0),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func Link(href string, rel string) Ren {
|
func Link(href string, rel string) Ren {
|
||||||
attributeMap := AttributeMap{
|
attributeMap := AttributeMap{
|
||||||
"href": href,
|
"href": href,
|
||||||
|
|
@ -75,6 +87,17 @@ func Link(href string, rel string) Ren {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ScriptWithVersion(url string, version string) Ren {
|
||||||
|
attributeMap := AttributeMap{
|
||||||
|
"src": url + "?v=" + version,
|
||||||
|
}
|
||||||
|
return &Element{
|
||||||
|
tag: "script",
|
||||||
|
attributes: attributeMap.ToMap(),
|
||||||
|
children: make([]Ren, 0),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func Script(url string) Ren {
|
func Script(url string) Ren {
|
||||||
attributeMap := AttributeMap{
|
attributeMap := AttributeMap{
|
||||||
"src": url,
|
"src": url,
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,20 @@
|
||||||
package base
|
package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/google/uuid"
|
||||||
"github.com/maddalax/htmgo/framework/h"
|
"github.com/maddalax/htmgo/framework/h"
|
||||||
"htmgo-site/partials"
|
"htmgo-site/partials"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var Version = uuid.NewString()[0:6]
|
||||||
|
|
||||||
func RootPage(children ...h.Ren) *h.Element {
|
func RootPage(children ...h.Ren) *h.Element {
|
||||||
return h.Html(
|
return h.Html(
|
||||||
h.HxExtension(h.BaseExtensions()),
|
h.HxExtension(h.BaseExtensions()),
|
||||||
h.Head(
|
h.Head(
|
||||||
h.Meta("viewport", "width=device-width, initial-scale=1"),
|
h.Meta("viewport", "width=device-width, initial-scale=1"),
|
||||||
h.Link("/public/main.css", "stylesheet"),
|
h.LinkWithVersion("/public/main.css", "stylesheet", Version),
|
||||||
h.Script("/public/htmgo.js"),
|
h.ScriptWithVersion("/public/htmgo.js", Version),
|
||||||
h.Raw(`
|
h.Raw(`
|
||||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||||
`),
|
`),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue