Refactor baseof template

This commit is contained in:
Zachary Betz 2019-02-12 23:11:59 -06:00
parent e8abc1d0ff
commit 4a3b86afb6
8 changed files with 111 additions and 106 deletions

View File

@ -1,105 +1,18 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="{{ .Site.Language.Lang }}">
<head> {{ partial "head.html" . }}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="canonical" href="{{ .Permalink }}">
<link rel="apple-touch-icon" sizes="57x57" href="{{ "images/apple-touch-icon-57x57.png" | absURL }}">
<link rel="apple-touch-icon" sizes="60x60" href="{{ "images/apple-touch-icon-60x60.png" | absURL }}">
<link rel="apple-touch-icon" sizes="72x72" href="{{ "images/apple-touch-icon-72x72.png" | absURL }}">
<link rel="apple-touch-icon" sizes="76x76" href="{{ "images/apple-touch-icon-76x76.png" | absURL }}">
<link rel="apple-touch-icon" sizes="114x114" href="{{ "images/apple-touch-icon-114x114.png" | absURL }}">
<link rel="apple-touch-icon" sizes="120x120" href="{{ "images/apple-touch-icon-120x120.png" | absURL }}">
<link rel="apple-touch-icon" sizes="144x144" href="{{ "images/apple-touch-icon-144x144.png" | absURL }}">
<link rel="apple-touch-icon" sizes="152x152" href="{{ "images/apple-touch-icon-152x152.png" | absURL }}">
<link rel="apple-touch-icon" sizes="180x180" href="{{ "images/apple-touch-icon-180x180.png" | absURL }}">
<link rel="icon" type="image/png" sizes="192x192" href="{{ "images/android-icon-192x192.png" | absURL }}">
<link rel="icon" type="image/png" sizes="32x32" href="{{ "images/favicon-32x32.png" | absURL }}">
<link rel="icon" type="image/png" sizes="96x96" href="{{ "images/favicon-96x96.png" | absURL }}">
<link rel="icon" type="image/png" sizes="16x16" href="{{ "images/favicon-16x16.png" | absURL }}">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="{{ "images/ms-icon-144x144.png" | absURL }}">
<meta name="theme-color" content="#ffffff">
<link rel="stylesheet" href="{{ "css/prism.css" | absURL }}" media="none" onload="this.media='all';">
<link rel="stylesheet" type="text/css" href="{{ "css/styles.css" | absURL }}">
<style id="inverter" media="none">
html { filter: invert(100%) }
* { background-color: inherit }
img:not([src*=".svg"]), .colors, iframe, .demo-container { filter: invert(100%) }
</style>
<title>
{{ .Title }} | {{ .Site.Title }}
</title>
{{ if .IsHome }}
<link rel="manifest" href="manifest.json">
{{ end }}
</head>
<body> <body>
<a href="#main">skip to content</a> <a href="#main">skip to content</a>
{{ partial "svg.html" . }} {{ partial "svg.html" . }}
<div class="wrapper"> <div class="wrapper">
<header class="intro-and-nav" role="banner"> {{ partial "header.html" . }}
<div>
<div class="intro">
<a class="logo" href="/" aria-label="{{ .Site.Title }} home page">
<img src="{{ "images/logo.svg" | absURL }}" alt="">
</a>
<p class="library-desc">
{{ .Site.Params.Description | markdownify }}
</a>
</p>
</div>
{{ block "nav" . }}
<nav id="patterns-nav" class="patterns" role="navigation">
<h2 class="vh">Main navigation</h2>
<button id="menu-button" aria-expanded="false">
<svg viewBox="0 0 50 50" aria-hidden="true" focusable="false">
<use xlink:href="#menu"></use>
</svg>
Menu
</button>
{{ $current := . }}
<ul id="patterns-list">
{{ range .Site.Menus.nav }}
<li class="pattern">
{{ $active := or ($current.IsMenuCurrent "nav" .) ($current.HasMenuCurrent "nav" .) }}
{{ $active = or $active (eq .Name $current.Title) }}
{{ $active = or $active (and (eq .Name "Blog") (eq $current.Section "post")) }}
{{ $active = or $active (and (eq .Name "Tags") (eq $current.Section "tags")) }}
<a href="{{ .URL }}" {{ if $active }}aria-current="page"{{ end }}>
<svg class="bookmark-icon" aria-hidden="true" focusable="false" viewBox="0 0 40 50">
<use xlink:href="#bookmark"></use>
</svg>
<span class="text">{{ .Name }}</span>
</a>
</li>
{{ end }}
</ul>
</nav>
{{ end }}
</div>
</header>
<div class="main-and-footer"> <div class="main-and-footer">
<div> <div>
{{ block "main" . }} {{ block "main" . }}{{ end }}
{{ end }} {{ partial "footer.html" . }}
<footer role="contentinfo">
<div>
<label for="themer">
dark theme: <input type="checkbox" id="themer" class="vh">
<span aria-hidden="true"></span>
</label>
</div>
{{ .Site.Params.footer | markdownify }}
</footer>
</div> </div>
</div> </div>
</div> </div>
<script src="{{ "js/prism.js" | absURL }}"></script> {{ partial "script.html" . }}
<script src="{{ "js/dom-scripts.js" | absURL }}"></script>
{{ if .Page.IsHome }}
<script src="{{ "js/service-worker-registration.js" | absURL }}"></script>
{{ end }}
</body> </body>
</html> </html>

View File

@ -1,10 +0,0 @@
<li>
<h2>
<a href="{{ .Permalink }}">
<svg class="bookmark" aria-hidden="true" viewBox="0 0 40 50" focusable="false">
<use xlink:href="#bookmark"></use>
</svg>
{{ .Title }}
</a>
</h2>
</li>

View File

@ -4,9 +4,18 @@
{{ .Title }} {{ .Title }}
</h1> </h1>
<ul class="patterns-list"> <ul class="patterns-list">
{{ range .Data.Pages }} {{ range .Pages.ByPublishDate.Reverse }}
{{ .Render "li" }} <li>
{{ end }} <h2>
<a href="{{ .Permalink }}">
<svg class="bookmark" aria-hidden="true" viewBox="0 0 40 50" focusable="false">
<use xlink:href="#bookmark"></use>
</svg>
{{ .Title }}
</a>
</h2>
</li>
{{ end }}
</ul> </ul>
</main> </main>
{{ end }} {{ end }}

View File

@ -0,0 +1,9 @@
<footer role="contentinfo">
<div>
<label for="themer">
dark theme: <input type="checkbox" id="themer" class="vh">
<span aria-hidden="true"></span>
</label>
</div>
{{ .Site.Params.footer | markdownify }}
</footer>

View File

@ -0,0 +1,39 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="canonical" href="{{ .Permalink }}">
<link rel="apple-touch-icon" sizes="57x57" href="{{ "images/apple-touch-icon-57x57.png" | absURL }}">
<link rel="apple-touch-icon" sizes="60x60" href="{{ "images/apple-touch-icon-60x60.png" | absURL }}">
<link rel="apple-touch-icon" sizes="72x72" href="{{ "images/apple-touch-icon-72x72.png" | absURL }}">
<link rel="apple-touch-icon" sizes="76x76" href="{{ "images/apple-touch-icon-76x76.png" | absURL }}">
<link rel="apple-touch-icon" sizes="114x114" href="{{ "images/apple-touch-icon-114x114.png" | absURL }}">
<link rel="apple-touch-icon" sizes="120x120" href="{{ "images/apple-touch-icon-120x120.png" | absURL }}">
<link rel="apple-touch-icon" sizes="144x144" href="{{ "images/apple-touch-icon-144x144.png" | absURL }}">
<link rel="apple-touch-icon" sizes="152x152" href="{{ "images/apple-touch-icon-152x152.png" | absURL }}">
<link rel="apple-touch-icon" sizes="180x180" href="{{ "images/apple-touch-icon-180x180.png" | absURL }}">
<link rel="icon" type="image/png" sizes="192x192" href="{{ "images/android-icon-192x192.png" | absURL }}">
<link rel="icon" type="image/png" sizes="32x32" href="{{ "images/favicon-32x32.png" | absURL }}">
<link rel="icon" type="image/png" sizes="96x96" href="{{ "images/favicon-96x96.png" | absURL }}">
<link rel="icon" type="image/png" sizes="16x16" href="{{ "images/favicon-16x16.png" | absURL }}">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="{{ "images/ms-icon-144x144.png" | absURL }}">
<meta name="theme-color" content="#ffffff">
<link rel="stylesheet" href="{{ "css/prism.css" | absURL }}" media="none" onload="this.media='all';">
<link rel="stylesheet" type="text/css" href="{{ "css/styles.css" | absURL }}">
<style id="inverter" media="none">
html { filter: invert(100%) }
* { background-color: inherit }
img:not([src*=".svg"]), .colors, iframe, .demo-container { filter: invert(100%) }
</style>
{{ $title := print .Title " | " .Site.Title }}
{{ if .IsHome }}
{{ $title = .Site.Title }}
{{ end }}
<title>
{{ $title }}
</title>
{{ if .IsHome }}
<link rel="manifest" href="manifest.json">
{{ end }}
</head>

View File

@ -0,0 +1,14 @@
<header class="intro-and-nav" role="banner">
<div>
<div class="intro">
<a class="logo" href="/" aria-label="{{ .Site.Title }} home page">
<img src="{{ "images/logo.svg" | absURL }}" alt="">
</a>
<p class="library-desc">
{{ .Site.Params.description | markdownify }}
</a>
</p>
</div>
{{ partial "nav.html" . }}
</div>
</header>

26
layouts/partials/nav.html Normal file
View File

@ -0,0 +1,26 @@
<nav id="patterns-nav" class="patterns" role="navigation">
<h2 class="vh">Main navigation</h2>
<button id="menu-button" aria-expanded="false">
<svg viewBox="0 0 50 50" aria-hidden="true" focusable="false">
<use xlink:href="#menu"></use>
</svg>
Menu
</button>
{{ $current := . }}
<ul id="patterns-list">
{{ range .Site.Menus.nav }}
<li class="pattern">
{{ $active := or ($current.IsMenuCurrent "nav" .) ($current.HasMenuCurrent "nav" .) }}
{{ $active = or $active (eq .Name $current.Title) }}
{{ $active = or $active (and (eq .Name "Blog") (eq $current.Section "post")) }}
{{ $active = or $active (and (eq .Name "Tags") (eq $current.Section "tags")) }}
<a href="{{ .URL }}" {{ if $active }}aria-current="page"{{ end }}>
<svg class="bookmark-icon" aria-hidden="true" focusable="false" viewBox="0 0 40 50">
<use xlink:href="#bookmark"></use>
</svg>
<span class="text">{{ .Name }}</span>
</a>
</li>
{{ end }}
</ul>
</nav>

View File

@ -0,0 +1,5 @@
<script src="{{ "js/prism.js" | absURL }}"></script>
<script src="{{ "js/dom-scripts.js" | absURL }}"></script>
{{ if .IsHome }}
<script src="{{ "js/service-worker-registration.js" | absURL }}"></script>
{{ end }}