Add new hybrid header layout

Ref: #282
pull/361/head
James Panther 2022-11-10 10:52:11 +11:00
parent ba113c3a3b
commit 4367628ebe
No known key found for this signature in database
GPG Key ID: D36F789E45745D17
7 changed files with 98 additions and 6 deletions

View File

@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Added
- Support for article thumbnails, covers and featured images
- Hybrid header layout that switches between the hamburger and basic menus at appropriate viewport sizes
- Traditional Chinese (Taiwan) translation ([#262](https://github.com/jpanther/congo/pull/262))
- New `list.paginationWidth` parameter to specify how many pagination links are generated before they are truncated
- Tailwind plugin for Prettier to standardise the order of CSS classes ([#268](https://github.com/jpanther/congo/pull/268))

View File

@ -2862,6 +2862,14 @@ body:has(#menu-controller:checked) {
margin-bottom: 0px;
}
.sm\:flex {
display: flex;
}
.sm\:hidden {
display: none;
}
.sm\:w-1\/2 {
width: 50%;
}

View File

@ -1,5 +1,5 @@
var fuse;
var showButton = document.getElementById("search-button");
var showButtons = document.querySelectorAll("[id^='search-button']");
var hideButton = document.getElementById("close-search-button");
var wrapper = document.getElementById("search-wrapper");
var modal = document.getElementById("search-modal");
@ -12,7 +12,9 @@ var indexed = false;
var hasResults = false;
// Listen for events
showButton.addEventListener("click", displaySearch);
showButtons.forEach((button) => {
button.addEventListener("click", displaySearch);
});
hideButton.addEventListener("click", hideSearch);
wrapper.addEventListener("click", hideSearch);
modal.addEventListener("click", function (event) {
@ -107,7 +109,7 @@ function fetchJSON(path, callback) {
function buildIndex() {
var baseURL = wrapper.getAttribute("data-url");
baseURL = baseURL.replace(/\/?$/, '/');
baseURL = baseURL.replace(/\/?$/, "/");
fetchJSON(baseURL + "index.json", function (data) {
var options = {
shouldSort: true,

View File

@ -16,7 +16,7 @@ enableCodeCopy = false
# robots = ""
[header]
layout = "basic" # valid options: basic, hamburger, custom
layout = "basic" # valid options: basic, hamburger, hybrid, custom
[footer]
showCopyright = true

View File

@ -16,7 +16,7 @@ mainSections = ["samples"]
# robots = ""
[header]
layout = "basic" # valid options: basic, hamburger, custom
layout = "basic" # valid options: basic, hamburger, hybrid, custom
[footer]
showCopyright = true

View File

@ -123,7 +123,7 @@ Many of the article defaults here can be overridden on a per article basis by sp
|`logo`|_Not set_|The relative path to the site logo file within the `assets/` folder. The logo file should be provided at 2x resolution and supports any image dimensions.|
|`mainSections`|_Not set_|The sections that should be displayed in the recent articles list. If not provided the section with the greatest number of articles is used.|
|`robots`|_Not set_|String that indicates how robots should handle your site. If set, it will be output in the page head. Refer to [Google's docs](https://developers.google.com/search/docs/advanced/robots/robots_meta_tag#directives) for valid values.|
|`header.layout`|`"basic"`|The layout of the page header and menu. Valid values are `basic`, `hamburger` or `custom`. When set to `custom`, you must provide your own layout by creating a `/layouts/partials/header/custom.html` file.|
|`header.layout`|`"basic"`|The layout of the page header and menu. Valid values are `basic`, `hamburger`, `hybrid` or `custom`. When set to `custom`, you must provide your own layout by creating a `/layouts/partials/header/custom.html` file.|
|`footer.showCopyright`|`true`|Whether or not to show the copyright string in the site footer. Note that the string itself can be customised using the `copyright` parameter in the [languages configuration](#language-and-i18n).|
|`footer.showThemeAttribution`|`true`|Whether or not to show the "powered by" theme attribution in the site footer. If you choose to disable this message, please consider attributing the theme somewhere else on your site (for example, on your about page).|
|`footer.showAppearanceSwitcher`|`false`|Whether or not to show the appearance switcher in the site footer. The browser's local storage is used to persist the visitor's preference.|

View File

@ -0,0 +1,81 @@
<header class="py-6 font-semibold text-neutral-900 dark:text-neutral print:hidden sm:py-10">
<nav class="flex justify-between">
{{/* Site logo/title */}}
<div class="z-40 flex flex-row">
{{ partial "logo.html" . }}
{{ partial "translations.html" . }}
</div>
{{ if or .Site.Menus.main (.Site.Params.enableSearch | default false) }}
{{/* Hamburger menu */}}
<label id="menu-button" for="menu-controller" class="block sm:hidden">
<input type="checkbox" id="menu-controller" class="hidden" />
<div class="cursor-pointer hover:text-primary-600 dark:hover:text-primary-400">
{{ partial "icon.html" "bars" }}
</div>
<div
id="menu-wrapper"
class="invisible fixed inset-0 z-30 m-auto h-screen w-screen cursor-default overflow-auto bg-neutral-100/50 opacity-0 backdrop-blur-sm transition-opacity dark:bg-neutral-900/50"
>
<ul
class="mx-auto flex w-full max-w-7xl list-none flex-col overflow-visible px-6 py-6 ltr:text-right rtl:text-left sm:px-14 sm:py-10 sm:pt-10 md:px-24 lg:px-32"
>
<li class="mb-1">
<span class="cursor-pointer hover:text-primary-600 dark:hover:text-primary-400"
>{{ partial "icon.html" "xmark" }}</span
>
</li>
{{ if .Site.Menus.main }}
{{ range .Site.Menus.main }}
<li class="mb-1">
<a
class="decoration-primary-500 hover:underline hover:decoration-2 hover:underline-offset-2"
href="{{ .URL }}"
title="{{ .Title }}"
>{{ .Name | markdownify | emojify }}</a
>
</li>
{{ end }}
{{ end }}
{{ if .Site.Params.enableSearch | default false }}
<li>
<button
id="search-button-2"
class="text-base hover:text-primary-600 dark:hover:text-primary-400"
title="{{ i18n "search.open_button_title" }}"
>
{{ partial "icon.html" "search" }}
</button>
</li>
{{ end }}
</ul>
</div>
</label>
{{/* Basic menu */}}
<ul class="hidden list-none flex-row ltr:text-right rtl:text-left sm:flex">
{{ if .Site.Menus.main }}
{{ range .Site.Menus.main }}
<li class="mb-1 sm:mb-0 ltr:sm:mr-7 ltr:sm:last:mr-0 rtl:sm:ml-7 rtl:sm:last:ml-0">
<a
class="decoration-primary-500 hover:underline hover:decoration-2 hover:underline-offset-2"
href="{{ .URL }}"
title="{{ .Title }}"
>{{ .Name | markdownify | emojify }}</a
>
</li>
{{ end }}
{{ end }}
{{ if .Site.Params.enableSearch | default false }}
<li class="ltr:sm:mr-7 ltr:sm:last:mr-0 rtl:sm:ml-7 rtl:sm:last:ml-0">
<button
id="search-button-1"
class="text-base hover:text-primary-600 dark:hover:text-primary-400"
title="{{ i18n "search.open_button_title" }}"
>
{{ partial "icon.html" "search" }}
</button>
</li>
{{ end }}
</ul>
{{ end }}
</nav>
</header>