mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 13:07:09 +00:00
refactor: move CDN assets to js/ folder
This commit is contained in:
parent
d0dddbfe01
commit
ddf745f39a
@ -24,15 +24,21 @@ async function main() {
|
||||
|
||||
// Fetch htmx.min.js
|
||||
await fetchAndSave(
|
||||
"https://cdn.sonr.io/js/htmx.min.js",
|
||||
"https://cdnjs.cloudflare.com/ajax/libs/htmx/2.0.2/htmx.min.js",
|
||||
"./assets/js/htmx.min.js",
|
||||
);
|
||||
|
||||
// Fetch alpine.min.js
|
||||
await fetchAndSave(
|
||||
"https://unpkg.com/alpinejs@latest/dist/cdn.min.js",
|
||||
"https://cdnjs.cloudflare.com/ajax/libs/alpinejs/3.14.1/cdn.min.js",
|
||||
"./assets/js/alpine.min.js",
|
||||
);
|
||||
|
||||
// Fetch dexie.min.js
|
||||
await fetchAndSave(
|
||||
"https://cdnjs.cloudflare.com/ajax/libs/dexie/4.0.8/dexie.min.js",
|
||||
"./assets/js/dexie.min.js",
|
||||
);
|
||||
}
|
||||
|
||||
main();
|
||||
|
2
pkg/nebula/assets/js/dexie.min.js
vendored
Normal file
2
pkg/nebula/assets/js/dexie.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -1,12 +1,13 @@
|
||||
package cdn
|
||||
|
||||
const (
|
||||
CDNPath = "https://cdn.sonr.id"
|
||||
PublicOrigin = "https://cdn.sonr.id"
|
||||
)
|
||||
|
||||
var (
|
||||
stylesHandle = templ.NewOnceHandle()
|
||||
alpineHandle = templ.NewOnceHandle()
|
||||
dexieHandle = templ.NewOnceHandle()
|
||||
htmxHandle = templ.NewOnceHandle()
|
||||
)
|
||||
|
||||
@ -22,6 +23,12 @@ templ Alpine() {
|
||||
}
|
||||
}
|
||||
|
||||
templ Dexie() {
|
||||
@dexieHandle.Once() {
|
||||
<script src={ "/js/dexie.min.js" }></script>
|
||||
}
|
||||
}
|
||||
|
||||
templ Htmx() {
|
||||
@htmxHandle.Once() {
|
||||
<script src={ "/js/htmx.min.js" }></script>
|
||||
|
@ -9,12 +9,13 @@ import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
const (
|
||||
CDNPath = "https://cdn.sonr.id"
|
||||
PublicOrigin = "https://cdn.sonr.id"
|
||||
)
|
||||
|
||||
var (
|
||||
stylesHandle = templ.NewOnceHandle()
|
||||
alpineHandle = templ.NewOnceHandle()
|
||||
dexieHandle = templ.NewOnceHandle()
|
||||
htmxHandle = templ.NewOnceHandle()
|
||||
)
|
||||
|
||||
@ -58,7 +59,7 @@ func Styles() templ.Component {
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs("/assets/css/styles.css")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/global/cdn/scripts.templ`, Line: 15, Col: 39}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/global/cdn/scripts.templ`, Line: 16, Col: 39}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -118,7 +119,7 @@ func Alpine() templ.Component {
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs("/js/alpine.min.js")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/global/cdn/scripts.templ`, Line: 21, Col: 35}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/global/cdn/scripts.templ`, Line: 22, Col: 35}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -138,7 +139,7 @@ func Alpine() templ.Component {
|
||||
})
|
||||
}
|
||||
|
||||
func Htmx() templ.Component {
|
||||
func Dexie() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
@ -176,9 +177,9 @@ func Htmx() templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var9 string
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs("/js/htmx.min.js")
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs("/js/dexie.min.js")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/global/cdn/scripts.templ`, Line: 27, Col: 33}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/global/cdn/scripts.templ`, Line: 28, Col: 34}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -190,7 +191,67 @@ func Htmx() templ.Component {
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
templ_7745c5c3_Err = htmxHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var8), templ_7745c5c3_Buffer)
|
||||
templ_7745c5c3_Err = dexieHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var8), templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func Htmx() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var10 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var10 == nil {
|
||||
templ_7745c5c3_Var10 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Var11 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script src=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var12 string
|
||||
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs("/js/htmx.min.js")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/global/cdn/scripts.templ`, Line: 34, Col: 33}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
templ_7745c5c3_Err = htmxHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var11), templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user