package components

import (
	"git.soup.land/soup/sxgo/ssr"
)

type Page struct {
	Title   string
	IsAdmin bool
	Content ssr.Renderable
}

func (p Page) Render(sw *ssr.Writer) error {
	sw.Tmpl(p, `
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>{{if .Title}}{{.Title}} - {{end}}Lookbook</title>
	<link rel="stylesheet" href="{{staticURL "css/app.css"}}">
</head>
<body>
	<header class="header">
		<a href="/" class="logo">LOOKBOOK</a>
		<nav class="nav">
			<a href="/">ALL</a>
		</nav>
	</header>
	<main class="main">
`)

	p.Content.Render(sw)
	return sw.Tmpl(p, `
	</main>
	<script src="{{staticURL "js/app.js"}}"></script>
	<script>
		window.IS_ADMIN = {{.IsAdmin}};
	</script>
</body>
</html>
`)
}
