diff options
Diffstat (limited to 'page.templ')
-rw-r--r-- | page.templ | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/page.templ b/page.templ new file mode 100644 index 0000000..d6c15ef --- /dev/null +++ b/page.templ @@ -0,0 +1,146 @@ +package main + +templ Page(config *Config, pkg *Package) { + <!DOCTYPE html> + <html lang="en"> + <head> + <meta charset="utf-8"/> + <meta name="viewport" content="width=device-width, initial-scale=1.0"/> + if pkg != nil { + <meta name="go-import" content={ importString(config, *pkg) }/> + <meta name="go-source" content={ sourceString(config, *pkg) }/> + } + <style> + :root { + --width: 800px; + --font-main: Verdana, sans-serif; + --font-secondary: Verdana, sans-serif; + --font-scale: 1em; + --background-color: #fff; + --heading-color: #222; + --text-color: #444; + --link-color: #3273dc; + --visited-color: #8b6fcb; + --code-background-color: #f2f2f2; + --code-color: #222; + --blockquote-color: #222; + --icon-external-link: url("/external-link.svg"); + } + + @media (prefers-color-scheme: dark) { + :root { + --background-color: #01242e; + --heading-color: #eee; + --text-color: #ddd; + --link-color: #8cc2dd; + --visited-color: #8b6fcb; + --code-background-color: #000; + --code-color: #ddd; + --blockquote-color: #ccc; + } + } + + body { + font-family: var(--font-secondary); + font-size: var(--font-scale); + margin: auto; + padding: 20px; + max-width: var(--width); + text-align: left; + background-color: var(--background-color); + word-wrap: break-word; + overflow-wrap: break-word; + line-height: 1.5; + color: var(--text-color); + } + + h1, + h2, + h3, + h4, + h5, + h6 { + font-family: var(--font-main); + color: var(--heading-color); + & > a { + color: var(--heading-color); + } + } + + a { + color: var(--link-color); + cursor: pointer; + } + + nav a { + margin-right: 8px; + } + + strong, + b { + color: var(--heading-color); + } + + main { + margin-top: 2ex; + line-height: 1.6; + } + + table { + width: 100%; + } + </style> + <title>{ config.Title }</title> + </head> + <body> + <header> + <h1>{ config.Title }</h1> + <nav> + for _, link := range config.Menu { + <a href={ templ.SafeURL(link.URL) }>{ link.Name }</a> + } + </nav> + </header> + <main> + { children... } + </main> + </body> + </html> +} + +templ ListPage(config *Config) { + @Page(config, nil) { + <table> + <thead> + <tr> + <th>Name</th> + <th>Source</th> + <th>Documentation</th> + </tr> + </thead> + <tbody> + for _, pkg := range config.Packages { + <tr> + <td>{ packageImportPath(config, pkg) }</td> + <td><a href={ templ.SafeURL(packageForgeURL(config, pkg)) }>Source </a></td> + <td> + @GodocBadge(config, pkg) + </td> + </tr> + } + </tbody> + </table> + } +} + +templ PackagePage(config *Config, pkg *Package) { + @Page(config, pkg) { + <p>You're probably looking for the <a href={ templ.SafeURL(godocURL(config, pkg)) }>documentation</a>.</p> + } +} + +templ GodocBadge(config *Config, pkg *Package) { + <a href={ templ.SafeURL(godocURL(config, pkg)) }> + Go Reference + </a> +} |