feat(layouts): base layout for all pages
This commit is contained in:
6
configs/info.go
Normal file
6
configs/info.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package configs
|
||||
|
||||
const (
|
||||
APP_NAME = "Comicverse"
|
||||
APP_VERSION = "0.0.0"
|
||||
)
|
||||
@@ -1,9 +1,58 @@
|
||||
package layouts
|
||||
|
||||
templ Page() {
|
||||
<html>
|
||||
import (
|
||||
"forge.capytal.company/capytalcode/project-comicverse/configs"
|
||||
)
|
||||
|
||||
type PageInfo struct {
|
||||
Title string
|
||||
Description string
|
||||
Author string
|
||||
Keywords string
|
||||
ThemeColor string
|
||||
Heading templ.Component
|
||||
}
|
||||
|
||||
func pageInfo(info []PageInfo) PageInfo {
|
||||
if len(info) != 0 {
|
||||
return info[0]
|
||||
}
|
||||
return PageInfo{}
|
||||
}
|
||||
|
||||
templ Page(i ...PageInfo) {
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<script type="module" src="/assets/js/entry.js"></script>
|
||||
// Page information
|
||||
if pageInfo(i).Title != "" {
|
||||
<title>{ pageInfo(i).Title + " - " + configs.APP_NAME }</title>
|
||||
} else {
|
||||
<title>Comicverse</title>
|
||||
}
|
||||
if pageInfo(i).Author != "" {
|
||||
<meta name="author" content={ pageInfo(i).Author }/>
|
||||
} else {
|
||||
<meta name="author" content={ configs.APP_NAME }/>
|
||||
}
|
||||
if pageInfo(i).Description != "" {
|
||||
<meta name="description" content={ pageInfo(i).Description }/>
|
||||
}
|
||||
<meta name="publisher" content={ configs.APP_NAME }/>
|
||||
// Page configuration
|
||||
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1"/>
|
||||
<meta name="referrer" content="strict-origin-when-cross-origin"/>
|
||||
<meta name="color-scheme" content="dark light"/>
|
||||
if pageInfo(i).ThemeColor != "" {
|
||||
<meta name="theme-color" content={ pageInfo(i).ThemeColor }/>
|
||||
}
|
||||
// Global styles
|
||||
<link href="/assets/css/uno.css" rel="stylesheet"/>
|
||||
// Global scripts
|
||||
<script type="module" src="/assets/js/entry.js" defer></script>
|
||||
// Additional heading
|
||||
if pageInfo(i).Heading != nil {
|
||||
@pageInfo(i).Heading
|
||||
}
|
||||
</head>
|
||||
<body>
|
||||
{ children... }
|
||||
|
||||
Reference in New Issue
Block a user