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 package components
templ Dayjs() { import "fmt"
<script src="/public/dayjs-1.11.10.min.js"></script> import "github.com/tigorlazuardi/redmage/views"
<script src="/public/dayjs-relativeTime-1.11.10.min.js"></script>
<script src="/public/dayjs-utc-1.11.10.min.js"></script> templ Dayjs(c *views.Context) {
<script src="/public/dayjs-timezone-1.11.10.min.js"></script> <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> <script>
dayjs.extend(window.dayjs_plugin_relativeTime) dayjs.extend(window.dayjs_plugin_relativeTime)
dayjs.extend(window.dayjs_plugin_utc) 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"/> <meta name="keywords" content="Reddit, Image, Downloader"/>
<link rel="stylesheet" href="/public/style.css"/> <link rel="stylesheet" href="/public/style.css"/>
<link rel="icon" href="/public/favicon.svg"/> <link rel="icon" href="/public/favicon.svg"/>
@Dayjs(vc)
@HTMX(vc) @HTMX(vc)
@ThemeChange(vc) @ThemeChange(vc)
if vc.Config.Bool("http.hotreload") { if vc.Config.Bool("http.hotreload") {

View file

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

View file

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