diff options
Diffstat (limited to 'layouts/partials')
| -rw-r--r-- | layouts/partials/account.html | 13 | ||||
| -rw-r--r-- | layouts/partials/head.html | 60 | ||||
| -rw-r--r-- | layouts/partials/navbar.html | 69 |
3 files changed, 142 insertions, 0 deletions
diff --git a/layouts/partials/account.html b/layouts/partials/account.html new file mode 100644 index 0000000..f3c2001 --- /dev/null +++ b/layouts/partials/account.html @@ -0,0 +1,13 @@ +<a + id="btn-signup" + href="https://app.flyscrape.com/login" + class="block ml-3 px-3 py-1 text-sm font-semibold text-center text-white transition-all duration-200 ease-in bg-black rounded-full cursor-pointer focus:outline-none focus:ring-4 focus:ring-primary-300 dark:bg-white dark:text-black dark:focus:ring-primary-800 whitespace-nowrap" + > + <span id="btn-signup-large" class="hidden md:inline">Sign In to Flyscrape Proxy</span> + <span id="btn-signup-small" class="md:hidden">Flyscrape Proxy</span> +</a> +<script> + if (document.cookie.includes("session=")) { + document.getElementById("btn-signup-large").innerText = "Open Flyscrape Proxy"; + } +</script> diff --git a/layouts/partials/head.html b/layouts/partials/head.html new file mode 100644 index 0000000..22cd4e0 --- /dev/null +++ b/layouts/partials/head.html @@ -0,0 +1,60 @@ +<head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + {{ if hugo.IsProduction -}} + <meta name="robots" content="index, follow" /> + {{ else -}} + <meta name="robots" content="noindex, nofollow" /> + {{ end -}} + {{ partialCached "favicons.html" . }} + <title> + {{ with .Title }}{{ . }} – {{ end -}} + {{ .Site.Title -}} + </title> + <meta name="description" content="{{ partial "utils/page-description.html" . }}" /> + + {{ with .Params.canonical }} + <link rel="canonical" href="{{ . }}" itemprop="url" /> + {{ else }} + <link rel="canonical" href="{{ .Permalink }}" itemprop="url" /> + {{ end }} + + {{ partial "opengraph.html" . }} + {{ template "_internal/schema.html" . -}} + {{ template "_internal/twitter_cards.html" . -}} + + {{ partialCached "head-css.html" . }} + + + <!-- Google Analytics --> + {{- if and (eq hugo.Environment "production") (or .Site.GoogleAnalytics .Site.Config.Services.GoogleAnalytics.ID) }} + <link rel="preconnect" href="https://www.googletagmanager.com" crossorigin /> + {{ partial "google-analytics.html" . }} + {{- end }} + + + <script> + /* Initialize light/dark mode */ + const defaultTheme = '{{ site.Params.theme.default | default `system`}}'; + + const setDarkTheme = () => { + document.documentElement.classList.add("dark"); + document.documentElement.style.colorScheme = "dark"; + } + const setLightTheme = () => { + document.documentElement.classList.remove("dark"); + document.documentElement.style.colorScheme = "light"; + } + + if ("color-theme" in localStorage) { + localStorage.getItem("color-theme") === "dark" ? setDarkTheme() : setLightTheme(); + } else { + defaultTheme === "dark" ? setDarkTheme() : setLightTheme(); + if (defaultTheme === "system") { + window.matchMedia("(prefers-color-scheme: dark)").matches ? setDarkTheme() : setLightTheme(); + } + } + </script> + + {{ partial "custom/head-end.html" . }} +</head> diff --git a/layouts/partials/navbar.html b/layouts/partials/navbar.html new file mode 100644 index 0000000..fbbac17 --- /dev/null +++ b/layouts/partials/navbar.html @@ -0,0 +1,69 @@ +{{- $logoPath := .Site.Params.navbar.logo.path | default "images/logo.svg" -}} +{{- $logoLink := .Site.Params.navbar.logo.link | default .Site.Home.RelPermalink -}} +{{- $logoWidth := .Site.Params.navbar.logo.width | default "20" -}} +{{- $logoHeight := .Site.Params.navbar.logo.height | default "20" -}} +{{- $logoDarkPath := .Site.Params.navbar.logo.dark | default $logoPath -}} + +{{- $navWidth := "max-w-[90rem]" -}} +{{- with .Site.Params.navbar.width -}} + {{ if eq . "normal" -}} + {{ $navWidth = "max-w-screen-xl" -}} + {{ else if eq . "full" -}} + {{ $navWidth = "max-w-full" -}} + {{ end -}} +{{- end -}} + +<div class="nav-container sticky top-0 z-20 w-full bg-transparent print:hidden"> + <div class="nav-container-blur pointer-events-none absolute z-[-1] h-full w-full bg-white dark:bg-dark shadow-[0_2px_4px_rgba(0,0,0,.02),0_1px_0_rgba(0,0,0,.06)] contrast-more:shadow-[0_0_0_1px_#000] dark:shadow-[0_-1px_0_rgba(255,255,255,.1)_inset] contrast-more:dark:shadow-[0_0_0_1px_#fff]"></div> + + <nav class="mx-auto flex items-center justify-end h-16 px-6 {{ $navWidth }}"> + <a class="flex items-center hover:opacity-75 ltr:mr-auto rtl:ml-auto" href="{{ $logoLink }}"> + {{- if (.Site.Params.navbar.displayLogo | default true) }} + <img class="block dark:hidden" src="{{ $logoPath | relURL }}" alt="{{ .Site.Title }}" height="{{ $logoHeight }}" width="{{ $logoWidth }}" /> + <img class="hidden dark:block" src="{{ $logoDarkPath | relURL }}" alt="{{ .Site.Title }}" height="{{ $logoHeight }}" width="{{ $logoWidth }}" /> + {{- end }} + <span class="mx-2 font-extrabold inline select-none" title="Flyscrape">Flyscrape</span> + </a> + + {{- $currentPage := . -}} + {{- range .Site.Menus.main -}} + {{- if eq .Params.type "search" -}} + {{- partial "search.html" (dict "params" .Params) -}} + {{- else if eq .Params.type "account" -}} + {{- partial "account.html" (dict "params" .Params) -}} + {{- else -}} + {{- $link := .URL -}} + {{- $external := strings.HasPrefix $link "http" -}} + {{- with .PageRef -}} + {{- if hasPrefix . "/" -}} + {{- $link = relLangURL (strings.TrimPrefix "/" .) -}} + {{- end -}} + {{- end -}} + + {{/* Display icon menu item */}} + {{- if .Params.icon -}} + {{- $rel := cond (eq .Params.icon "mastodon") "noreferer me" "noreferer" }} + <a class="p-2 text-current" {{ if $external }}target="_blank" rel="{{ $rel }}"{{ end }} href="{{ $link }}" title="{{ or (T .Identifier) .Name | safeHTML }}"> + {{- partial "utils/icon.html" (dict "name" .Params.icon "attributes" "height=24") -}} + <span class="sr-only">{{ or (T .Identifier) .Name | safeHTML }}</span> + </a> + {{- else -}} + {{- $active := or ($currentPage.HasMenuCurrent "main" .) ($currentPage.IsMenuCurrent "main" .) -}} + {{- $activeClass := cond $active "font-medium" "text-gray-600 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200" -}} + <a + title="{{ or (T .Identifier) .Name | safeHTML }}" + href="{{ $link }}" + {{ if $external }}target="_blank" rel="noreferer"{{ end }} + class="text-sm contrast-more:text-gray-700 contrast-more:dark:text-gray-100 relative -ml-2 hidden whitespace-nowrap py-2 px-3 md:inline-block {{ $activeClass }}" + > + <span class="text-center">{{ or (T .Identifier) .Name | safeHTML }}</span> + </a> + {{- end -}} + {{- end -}} + {{- end -}} + + <button type="button" aria-label="Menu" class="hamburger-menu -mr-2 rounded p-2 active:bg-gray-400/20 md:hidden"> + {{- partial "utils/icon.html" (dict "name" "hamburger-menu" "attributes" "height=24") -}} + </button> + </nav> +</div> |