Skip to content

Commit

Permalink
refactor: move CDN assets to js/ folder
Browse files Browse the repository at this point in the history
  • Loading branch information
prnk28 committed Oct 8, 2024
1 parent d0dddbf commit ddf745f
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 10 deletions.
10 changes: 8 additions & 2 deletions pkg/nebula/.deps.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 2 additions & 0 deletions pkg/nebula/assets/js/dexie.min.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion pkg/nebula/global/cdn/scripts.templ
Original file line number Diff line number Diff line change
@@ -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()
)

Expand All @@ -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>
Expand Down
75 changes: 68 additions & 7 deletions pkg/nebula/global/cdn/scripts_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ddf745f

Please sign in to comment.