update assets use

This commit is contained in:
2024-12-11 17:37:58 +08:00
parent f6c961adb6
commit af08d9befc
25 changed files with 177 additions and 218 deletions

View File

@@ -3,12 +3,12 @@ package home
import (
"github.com/zhang2092/go-url-shortener/internal/db"
"github.com/zhang2092/go-url-shortener/internal/templ/base"
"github.com/zhang2092/go-url-shortener/internal/templ/funcs"
"github.com/zhang2092/go-url-shortener/internal/templ/util"
"net/http"
)
templ Home(r *http.Request, page string, data []*db.UserRelateUrl) {
@base.Base(page) {
templ Home(r *http.Request, data []*db.UserRelateUrl, assets ...string) {
@base.Base(assets...) {
<div class="container-fluid flex justify-content">
<div class="main">
<h3 style="margin-top: 20px;margin-bottom: 10px;">
@@ -44,7 +44,7 @@ templ Home(r *http.Request, page string, data []*db.UserRelateUrl) {
</tr>
}
</table>
@templ.Raw(funcs.CsrfField(r))
@templ.Raw(util.CsrfField(r))
</div>
</div>
}

View File

@@ -11,11 +11,11 @@ import templruntime "github.com/a-h/templ/runtime"
import (
"github.com/zhang2092/go-url-shortener/internal/db"
"github.com/zhang2092/go-url-shortener/internal/templ/base"
"github.com/zhang2092/go-url-shortener/internal/templ/funcs"
"github.com/zhang2092/go-url-shortener/internal/templ/util"
"net/http"
)
func Home(r *http.Request, page string, data []*db.UserRelateUrl) templ.Component {
func Home(r *http.Request, data []*db.UserRelateUrl, assets ...string) 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 {
@@ -135,7 +135,7 @@ func Home(r *http.Request, page string, data []*db.UserRelateUrl) templ.Componen
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templ.Raw(funcs.CsrfField(r)).Render(ctx, templ_7745c5c3_Buffer)
templ_7745c5c3_Err = templ.Raw(util.CsrfField(r)).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -145,7 +145,7 @@ func Home(r *http.Request, page string, data []*db.UserRelateUrl) templ.Componen
}
return templ_7745c5c3_Err
})
templ_7745c5c3_Err = base.Base(page).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
templ_7745c5c3_Err = base.Base(assets...).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}