feat: serving static files

for example htmx library
in the future tailwindcss out.css file as well
This commit is contained in:
efim 2023-10-06 10:31:50 +00:00
parent a9fce1bcbf
commit bb418101dd
3 changed files with 14 additions and 0 deletions

View File

@ -16,8 +16,17 @@ import (
//go:embed templates //go:embed templates
var templatesFS embed.FS var templatesFS embed.FS
//go:embed static
var staticFilesFS embed.FS
func AddPageRoutes(app *pocketbase.PocketBase) { func AddPageRoutes(app *pocketbase.PocketBase) {
app.OnBeforeServe().Add(getIndexPageRoute(app)) app.OnBeforeServe().Add(getIndexPageRoute(app))
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
e.Router.StaticFS("/static", staticFilesFS)
// this path works : http://127.0.0.1:8090/static/static/public/htmx.min.js
return nil
})
} }
// render and return index page // render and return index page

1
pages/static/public/htmx.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -13,6 +13,10 @@
defer defer
src="https://cdn.jsdelivr.net/gh/pocketbase/js-sdk@master/dist/pocketbase.umd.js" src="https://cdn.jsdelivr.net/gh/pocketbase/js-sdk@master/dist/pocketbase.umd.js"
></script> ></script>
<script
defer
src="/static/static/public/htmx.min.js"
></script>
<script defer type="text/javascript"> <script defer type="text/javascript">
async function callOauth(providerName) { async function callOauth(providerName) {
const pb = new PocketBase("http://127.0.0.1:8090"); const pb = new PocketBase("http://127.0.0.1:8090");