dayjs: now support dynamic versioning

This commit is contained in:
Tigor Hutasuhut 2024-05-01 16:10:04 +07:00
parent 3c26baa3cf
commit 4ca2e854d4
4 changed files with 10 additions and 7 deletions

View file

@ -1,10 +1,13 @@
package components
templ Dayjs() {
<script src="/public/dayjs-1.11.10.min.js"></script>
<script src="/public/dayjs-relativeTime-1.11.10.min.js"></script>
<script src="/public/dayjs-utc-1.11.10.min.js"></script>
<script src="/public/dayjs-timezone-1.11.10.min.js"></script>
import "fmt"
import "github.com/tigorlazuardi/redmage/views"
templ Dayjs(c *views.Context) {
<script src={ fmt.Sprintf("/public/dayjs-%s.min.js", c.Config.String("web.dependencies.dayjs.version")) }></script>
<script src={ fmt.Sprintf("/public/dayjs-relativeTime-%s.min.js", c.Config.String("web.dependencies.dayjs.version")) }></script>
<script src={ fmt.Sprintf("/public/dayjs-utc-%s.min.js", c.Config.String("web.dependencies.dayjs.version")) }></script>
<script src={ fmt.Sprintf("/public/dayjs-timezone-%s.min.js", c.Config.String("web.dependencies.dayjs.version")) }></script>
<script>
dayjs.extend(window.dayjs_plugin_relativeTime)
dayjs.extend(window.dayjs_plugin_utc)

View file

@ -8,6 +8,7 @@ templ Head(vc *views.Context, extras ...templ.Component) {
<meta name="keywords" content="Reddit, Image, Downloader"/>
<link rel="stylesheet" href="/public/style.css"/>
<link rel="icon" href="/public/favicon.svg"/>
@Dayjs(vc)
@HTMX(vc)
@ThemeChange(vc)
if vc.Config.Bool("http.hotreload") {

View file

@ -87,7 +87,7 @@ templ Navbar(c *views.Context) {
<span class="font-bold">Redmage</span>
</div>
<div class="divider"></div>
<nav class="pt-4">
<nav class="pt-4" hx-boost="true" hx-select="main" hx-target="main">
@navList(c)
</nav>
<div class="flex-grow"></div>

View file

@ -9,7 +9,6 @@ import "fmt"
templ Home(c *views.Context, data Data) {
@components.Doctype() {
@components.Head(c,
components.Dayjs(),
components.HeadTitle("Redmage - Home"),
)
@components.Body(c) {