This commit is contained in:
1 parent
c08dd355c0
commit
297efaa4a6
3 files changed
+45
-24
No files matched your search
+36
-23
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
templ Head(cfg config.Cfg, title string) {
|
||||
templ head(cfg config.Cfg, title string) {
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
@@ -29,29 +29,42 @@ templ Head(cfg config.Cfg, title string) {
|
||||
templ Base(cfg config.Cfg, title string) {
|
||||
<!DOCTYPE html>
|
||||
<html lang={ translate.Language(ctx) }>
|
||||
@Head(cfg, title)
|
||||
<body class="bg-black dark" hx-boost="true" hx-target="main" hx-ext="head-support,preload,preload-links">
|
||||
<header
|
||||
class="fixed z-50 mix-blend-difference p-1 w-full flex justify-between items-start"
|
||||
>
|
||||
<a class="text-white text-2xl" href={ translate.Path(ctx, "") } preload="mouseover" preload-images="true">schreifuchs.ch</a>
|
||||
<nav class="flex gap-2 p-2">
|
||||
for _, lang := range translate.SupportedLanguages(ctx) {
|
||||
<a
|
||||
href={ translate.PathForLang(ctx, lang, strings.Split(templer.Path(ctx), "/")...) }
|
||||
hreflang={ lang }
|
||||
data-no-translate
|
||||
preload="mouseover"
|
||||
class="text-white hover:underline uppercase"
|
||||
>
|
||||
{ lang }
|
||||
</a>
|
||||
}
|
||||
</nav>
|
||||
</header>
|
||||
<main class="text-white">
|
||||
@head(cfg, title)
|
||||
<body class="bg-black dark" hx-boost="true" hx-target="body" hx-ext="head-support,preload,preload-links">
|
||||
@body() {
|
||||
{ children... }
|
||||
</main>
|
||||
}
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
|
||||
templ Content(cfg config.Cfg, title string) {
|
||||
@head(cfg, title)
|
||||
@body() {
|
||||
{ children... }
|
||||
}
|
||||
}
|
||||
|
||||
templ body() {
|
||||
<header
|
||||
class="fixed z-50 mix-blend-difference p-1 w-full flex justify-between items-start"
|
||||
>
|
||||
<a class="text-white text-2xl" href={ translate.Path(ctx, "") } preload="mouseover" preload-images="true">schreifuchs.ch</a>
|
||||
<nav class="flex gap-2 p-2">
|
||||
for _, lang := range translate.SupportedLanguages(ctx) {
|
||||
<a
|
||||
href={ translate.PathForLang(ctx, lang, strings.Split(templer.Path(ctx), "/")...) }
|
||||
hreflang={ lang }
|
||||
data-no-translate
|
||||
preload="mouseover"
|
||||
class="text-white hover:underline uppercase"
|
||||
>
|
||||
{ lang }
|
||||
</a>
|
||||
}
|
||||
</nav>
|
||||
</header>
|
||||
<main class="text-white">
|
||||
{ children... }
|
||||
</main>
|
||||
}
|
||||
@@ -36,7 +36,7 @@ func (l *Layouts) Render(ctx context.Context, w io.Writer, r *http.Request, comp
|
||||
component = Base(l.cfg, title)
|
||||
} else {
|
||||
ctx = templ.WithChildren(ctx, component)
|
||||
component = Head(l.cfg, title)
|
||||
component = Content(l.cfg, title)
|
||||
}
|
||||
|
||||
if err := component.Render(ctx, w); err != nil {
|
||||
|
||||
Reference in new issue
Block a user