feat: allow disable toc on page frontmatter

refactor: move pager to partial/components

chore: add head-css and favicons

- support favicons and page descriptions
- dynamic title based on page
- add custom head-end hook

feat: add opengraph to head

fix: sidebar not hiding when resizing
This commit is contained in:
Xin
2023-08-09 22:57:43 +01:00
parent ad3c607623
commit 750e566d24
11 changed files with 96 additions and 40 deletions

View File

@ -1,35 +1,37 @@
{{/* Table of Contents */}}
{{/* TODO: toc should be able to get disabled through page frontmatter */}}
{{/* TODO: toc bottom part should be able to hide */}}
<div class="order-last hidden w-64 shrink-0 xl:block print:hidden px-4" aria-label="table of contents">
<div class="sticky top-16 overflow-y-auto pr-4 pt-6 text-sm [hyphens:auto] max-h-[calc(100vh-4rem-env(safe-area-inset-bottom))] ltr:-mr-4 rtl:-ml-4">
{{ with .Fragments.Headings }}
<p class="mb-4 font-semibold tracking-tight">On This Page</p>
{{ range . }}
<ul>
{{ with .Headings }}
{{ template "side-toc-subheading" (dict "headings" . "level" 0) }}
{{ end }}
</ul>
{{- $toc := .Params.toc | default true -}}
<nav class="order-last hidden w-64 shrink-0 xl:block print:hidden px-4" aria-label="table of contents">
{{ if $toc }}
<div class="sticky top-16 overflow-y-auto pr-4 pt-6 text-sm [hyphens:auto] max-h-[calc(100vh-4rem-env(safe-area-inset-bottom))] ltr:-mr-4 rtl:-ml-4">
{{ with .Fragments.Headings }}
<p class="mb-4 font-semibold tracking-tight">On This Page {{ $toc }}</p>
{{ range . }}
<ul>
{{ with .Headings }}
{{ template "toc-subheading" (dict "headings" . "level" 0) }}
{{ end }}
</ul>
{{ end }}
{{ end }}
{{ end }}
{{ $borderClass := "mt-8 border-t bg-white pt-8 shadow-[0_-12px_16px_white] dark:bg-dark dark:shadow-[0_-12px_16px_#111]" }}
{{ if not .Fragments.Headings }}
{{ $borderClass = "" }}
{{ end }}
{{ $borderClass := "mt-8 border-t bg-white pt-8 shadow-[0_-12px_16px_white] dark:bg-dark dark:shadow-[0_-12px_16px_#111]" }}
{{ if not .Fragments.Headings }}
{{ $borderClass = "" }}
{{ end }}
<div class="{{ $borderClass }} sticky bottom-0 flex flex-col items-start gap-2 pb-8 dark:border-neutral-800 contrast-more:border-t contrast-more:border-neutral-400 contrast-more:shadow-none contrast-more:dark:border-neutral-400">
<a class="text-xs font-medium text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100 contrast-more:text-gray-800 contrast-more:dark:text-gray-50" href="{{ .Params.editURL }}">Edit this page on GitHub →</a>
<div class="{{ $borderClass }} sticky bottom-0 flex flex-col items-start gap-2 pb-8 dark:border-neutral-800 contrast-more:border-t contrast-more:border-neutral-400 contrast-more:shadow-none contrast-more:dark:border-neutral-400">
<a class="text-xs font-medium text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100 contrast-more:text-gray-800 contrast-more:dark:text-gray-50" href="{{ .Params.editURL }}">Edit this page on GitHub →</a>
</div>
</div>
</div>
</div>
{{ end }}
</nav>
{{/* TOC subheading component.
This is a recursive component that renders a list of headings.
*/}}
{{- define "side-toc-subheading" -}}
{{/* TOC subheadings component. This is a recursive component that renders a list of headings. */}}
{{- define "toc-subheading" -}}
{{ $headings := .headings }}
{{ $level := .level }}
{{ if ge $level 6 }}
@ -48,7 +50,7 @@
</li>
{{ end }}
{{ with .Headings }}
{{ template "side-toc-subheading" (dict "headings" . "level" (add $level 1)) }}
{{ template "toc-subheading" (dict "headings" . "level" (add $level 1)) }}
{{ end }}
{{ end }}