78 lines
1.5 KiB
Plaintext
78 lines
1.5 KiB
Plaintext
package components
|
|
|
|
templ Layout(props LayoutProps) {
|
|
<!DOCTYPE html>
|
|
<html lang="en" data-theme="corporate">
|
|
<head>
|
|
<meta charset="UTF-8"/>
|
|
<title>{ props.Title }</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
<meta name="description" content={ props.Description }/>
|
|
@Head(props.Head)
|
|
</head>
|
|
<body>
|
|
@Header(props.Header)
|
|
<main>
|
|
{ children... }
|
|
</main>
|
|
</body>
|
|
</html>
|
|
}
|
|
|
|
type LayoutProps struct {
|
|
Title string
|
|
Description string
|
|
Head HeadProps
|
|
Header HeaderProps
|
|
}
|
|
|
|
templ Head(props HeadProps) {
|
|
for _, link := range props.Links {
|
|
<link href={ link.Href } rel={ link.Rel } as={ link.As }/>
|
|
}
|
|
for _, script := range props.Scripts {
|
|
<script src={ script.Src } defer={ script.Defer }></script>
|
|
}
|
|
}
|
|
|
|
type HeadProps struct {
|
|
Links []Link
|
|
Scripts []Script
|
|
}
|
|
|
|
type Link struct {
|
|
Href string
|
|
Rel string
|
|
As string
|
|
}
|
|
|
|
type Script struct {
|
|
Src string
|
|
Defer bool
|
|
}
|
|
|
|
templ Header(props HeaderProps) {
|
|
<header class="navbar bg-primary text-primary-content px-6">
|
|
<div class="navbar-start">
|
|
<span class="font-semibold mr-5">{ props.Title }</span>
|
|
</div>
|
|
<div class="navbar-center">
|
|
if props.NavbarCenter != nil {
|
|
@props.NavbarCenter
|
|
}
|
|
</div>
|
|
<div class="navbar-end">
|
|
if props.NavbarEnd != nil {
|
|
@props.NavbarEnd
|
|
}
|
|
</div>
|
|
</header>
|
|
}
|
|
|
|
type HeaderProps struct {
|
|
Title string
|
|
NavbarStart templ.Component
|
|
NavbarCenter templ.Component
|
|
NavbarEnd templ.Component
|
|
}
|