Make sidebar optional, make it possible to overide all parmas per post.

This commit is contained in:
Fredrik Jonsson 2017-05-16 15:37:22 +02:00
commit 0299c650d5
10 changed files with 27 additions and 68 deletions

View file

@ -7,14 +7,14 @@
{{ block "meta" . }}{{ end }}
</head>
<body class="one-sidebar sidebar-second">
<body class="{{ if $.Param "sidebar" | default true }}one-sidebar sidebar-second{{ else }}no-sidebars{{ end }}">
<div class="layout-center">
<header class="header" role="banner">
<a href="{{ .Site.BaseURL }}" title="Home" rel="home" class="header__logo"><img src="/images/logo.png" alt="Home" class="header__logo-image" /></a>
{{ if $.Param "logo" | default true }}<a href="{{ .Site.BaseURL }}" title="Home" rel="home" class="header__logo"><img src="/images/logo.png" alt="Home" class="header__logo-image" /></a>{{ end }}
<h1 class="header__site-name">
<a href="{{ .Site.BaseURL }}" title="Home" class="header__site-link" rel="home"><span>{{ .Site.Title }}</span></a>
</h1>
<div class="header__region region region-header">{{ if .Site.Params.search }}{{ partialCached "search.html" . }}{{ end }}</div>
<div class="header__region region region-header">{{ if $.Param "search" }}{{ partialCached "search.html" . }}{{ end }}</div>
</header>
<div class="layout-3col layout-swap">
@ -22,9 +22,9 @@
</div>
<footer class="footer" role="contentinfo">
<p>{{ with .Site.Params.copyright }}{{ . | markdownify }}{{ else }}<span>&copy; {{ .Site.Title }}</span>{{ end }}</p>
{{ with .Site.Params.footer }}<p>{{ . | markdownify }}</p>{{ end }}
{{ if .Site.Params.poweredby }}<p>Powered by <a href="https://gohugo.io/">Hugo</a></p>{{ end }}
<p>{{ with $.Param "copyright" }}{{ . | markdownify }}{{ else }}<span>&copy; {{ .Site.Title }}</span>{{ end }}</p>
{{ with $.Param "footer" }}<p>{{ . | markdownify }}</p>{{ end }}
{{ if $.Param "poweredby" }}<p>Powered by <a href="https://gohugo.io/">Hugo</a></p>{{ end }}
</footer>
</div>
{{ partialCached "scripts.html" . }}

View file

@ -5,20 +5,15 @@
{{ end }}
{{ define "main" }}
<main class="layout-3col__left-content" role="main">
{{ range .Data.Pages }}
<article class="{{ with .Section }}section-{{ . | urlize }}{{ end }} list-view">
<header>
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a><h2>
</header>
<div>
{{ .Summary }}
</div>
</article>
<main class="{{ if $.Param "sidebar" | default true }}layout-3col__left-content{{ else }}layout-3col__full{{ end }}" role="main">
{{ $paginator := .Paginate (.Data.Pages) }}
{{ range $paginator.Pages }}
{{ .Render "summary"}}
{{ end }}
{{ partial "pagination.html" . }}
</main>
{{ partial "menu.html" . }}
{{ partial "sidebar.html" . }}
{{ if $.Param "sidebar" | default true }}{{ partial "sidebar.html" . }}{{ end }}
{{ end }}

View file

@ -2,11 +2,10 @@
{{ define "meta" }}
{{ partial "single_meta.html" . }}
{{ partial "single_json_ld.html" . }}
{{ end }}
{{ define "main" }}
<main class="layout-3col__left-content" role="main">
<main class="{{ if $.Param "sidebar" | default true }}layout-3col__left-content{{ else }}layout-3col__full{{ end }}" role="main">
<h1>{{ .Title }}</h1>
<article class="{{ with .Section }}section-{{ . | urlize }}{{ end }} single-view">
<header>
@ -18,5 +17,5 @@
</main>
{{ partial "menu.html" . }}
{{ partial "sidebar.html" . }}
{{ if $.Param "sidebar" | default true }}{{ partial "sidebar.html" . }}{{ end }}
{{ end }}

View file

@ -1,14 +1,13 @@
{{ define "meta" }}
{{ partial "single_meta.html" . }}
{{ partial "single_json_ld.html" . }}
{{ end }}
{{ define "main" }}
<main class="layout-3col__left-content" role="main">
<article>
<main class="{{ if $.Param "sidebar" | default true }}layout-3col__left-content{{ else }}layout-3col__full{{ end }}" role="main">
<article class="{{ with .Section }}section-{{ . | urlize }}{{ end }} single-view">
{{ .Content }}
</article>
</main>
{{ partial "menu.html" . }}
{{ partial "sidebar.html" . }}
{{ if $.Param "sidebar" | default true }}{{ partial "sidebar.html" . }}{{ end }}
{{ end }}

View file

@ -2,9 +2,9 @@
<meta name="MobileOptimized" content="width">
<meta name="HandheldFriendly" content="true">
{{ .Hugo.Generator }}
<link rel="stylesheet" href="/css/styles.css{{ if .Site.Params.cacheBustCSS }}?{{ readFile "/public/css/styles.css" | sha1 }}{{ end }}">
<link rel="stylesheet" href="/css/styles.css{{ if $.Param "cacheBustCSS" }}?{{ readFile "/public/css/styles.css" | sha1 }}{{ end }}">
<link rel="canonical" href="{{ .Permalink }}">
<link rel="shortcut icon" href="/favicon.ico" type="image/vnd.microsoft.icon">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
{{ if and (.Site.RSSLink) (not .Site.Params.supressRSSLink) }}<link rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}" href="{{ .Site.RSSLink }}">{{ end }}
{{ with .Site.Params.contact }}<meta name="contact" content="{{ . }}">{{ end }}
{{ if and (.Site.RSSLink) (not ($.Param "supressRSSLink")) }}<link rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}" href="{{ .Site.RSSLink }}">{{ end }}
{{ with $.Param "contact" }}<meta name="contact" content="{{ . }}">{{ end }}

View file

@ -1,3 +1,3 @@
{{ if .Site.Params.jquery }}<script src="/js/jquery.min.js"></script>{{ end }}
{{ if and .Site.Params.jquery .Site.Params.slicknav }}<script src="/js/jquery.slicknav.min.js"></script>{{ end }}
{{ if .Site.Params.jquery }}<script src="/js/script.js{{ if .Site.Params.cacheBustJS }}?{{ readFile "/public/js/script.js" | sha1 }}{{ end }}"></script>{{ end }}
{{ if $.Param "jquery" }}<script src="/js/jquery.min.js"></script>{{ end }}
{{ if and ($.Param "jquery") ($.Param "slicknav") }}<script src="/js/jquery.slicknav.min.js"></script>{{ end }}
{{ if $.Param "jquery" }}<script src="/js/script.js{{ if $.Param "cacheBustJS" }}?{{ readFile "/public/js/script.js" | sha1 }}{{ end }}"></script>{{ end }}

View file

@ -1,6 +1,6 @@
{{ $domain := .Site.BaseURL | replaceRE "^https?://(www\\.)?([^/]+)/?" "$2" }}
<form class="search-form" method="get" action="https://duckduckgo.com/">
<input type="search" name="q" class="search-text" placeholder="Search this site…" title="Enter the terms you wish to search for." size="{{ .Site.Params.searchSize | default "20" }}" maxlength="128">
<input type="search" name="q" class="search-text" placeholder="Search this site…" title="Enter the terms you wish to search for." size="{{ $.Param "searchSize" | default "20" }}" maxlength="128">
<input type="hidden" name="sites" value="{{ $domain }}">
<input type="submit" value="DuckDuckGo Search" class="hidden">
</form>

View file

@ -1 +1 @@
{{ if and (.RSSLink) (not .Site.Params.supressRSSLink) }}<link rel="alternate" type="application/rss+xml" title="{{ .Title }} - {{ .Site.Title }}" href="{{ .RSSLink }}">{{ end }}
{{ if and (.RSSLink) (not ($.Param "supressRSSLink")) }}<link rel="alternate" type="application/rss+xml" title="{{ .Title }} - {{ .Site.Title }}" href="{{ .RSSLink }}">{{ end }}

View file

@ -1,34 +0,0 @@
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "NewsArticle",
"mainEntityOfPage": {
"@type": "WebPage",
"@id":"{{ .Site.BaseURL }}"
},
"headline": "{{ .Title }} - {{ .Site.Title }}",
"image": {
"@type": "ImageObject",
"url": "{{ .Site.BaseURL }}{{ .Params.thumbnail | default "images/default.png" }}",
"height": 800,
"width": 800
},
"datePublished": "{{ .Date.Format "2006-01-02T15:04:05UTC" }}",
"dateModified": "{{ .Lastmod.Format "2006-01-02T15:04:05UTC" }}",
"author": {
"@type": "Person",
"name": "{{ .Site.Title }}"
},
"publisher": {
"@type": "Organization",
"name": "{{ .Site.Title }}",
"logo": {
"@type": "ImageObject",
"url": "{{ .Site.BaseURL }}images/logo.png",
"width": 600,
"height": 60
}
},
"description": "{{ .Description | default .Summary }}"
}
</script>

View file

@ -5,4 +5,4 @@
<meta property="og:site_name" content="{{ .Site.Title }}">
<meta property="og:description" content="{{ replaceRE "\n" "" (.Description | default .Summary) }}">
<meta property="og:locale" content="{{ .Lang }}">
{{ with .Params.thumbnail }}<meta property="og:image" content="{{ .Site.BaseURL }}{{ . }}">{{ end }}
{{ with $.Param "thumbnail" }}<meta property="og:image" content="{{ .Site.BaseURL }}{{ . }}">{{ end }}