chore: add displayPlaceholder option to sidebar

This commit is contained in:
Xin 2023-08-24 22:29:53 +01:00
parent d14091cd81
commit 97f31e92a7
5 changed files with 10 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{{ define "main" }} {{ define "main" }}
<div class="mx-auto flex max-w-screen-xl"> <div class="mx-auto flex max-w-screen-xl">
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true) }} {{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
{{ partial "toc.html" . }} {{ partial "toc.html" . }}
<article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]"> <article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
<main class="w-full min-w-0 max-w-6xl px-6 pt-4 md:px-12"> <main class="w-full min-w-0 max-w-6xl px-6 pt-4 md:px-12">

View File

@ -1,6 +1,6 @@
{{ define "main" }} {{ define "main" }}
<div class="mx-auto flex max-w-screen-xl"> <div class="mx-auto flex max-w-screen-xl">
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true) }} {{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
<article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]"> <article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
<main class="w-full min-w-0 max-w-6xl px-6 pt-4 md:px-12"> <main class="w-full min-w-0 max-w-6xl px-6 pt-4 md:px-12">
<h1 class="text-4xl tracking-tighter text-center font-extrabold md:text-5xl mt-8 pb-6">{{ .Title }}</h1> <h1 class="text-4xl tracking-tighter text-center font-extrabold md:text-5xl mt-8 pb-6">{{ .Title }}</h1>

View File

@ -1,6 +1,6 @@
{{ define "main" }} {{ define "main" }}
<div class="mx-auto flex max-w-screen-xl"> <div class="mx-auto flex max-w-screen-xl">
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true) }} {{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
{{ partial "toc.html" . }} {{ partial "toc.html" . }}
<article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]"> <article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
<main class="w-full min-w-0 max-w-6xl px-6 pt-4 md:px-12"> <main class="w-full min-w-0 max-w-6xl px-6 pt-4 md:px-12">

View File

@ -1,6 +1,6 @@
{{ define "main" }} {{ define "main" }}
<div class="mx-auto flex max-w-screen-xl"> <div class="mx-auto flex max-w-screen-xl">
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true) }} {{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
{{ partial "toc.html" . }} {{ partial "toc.html" . }}
<article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]"> <article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
<main class="w-full min-w-0 max-w-6xl px-6 pt-4 md:px-12"> <main class="w-full min-w-0 max-w-6xl px-6 pt-4 md:px-12">

View File

@ -1,6 +1,9 @@
{{- $context := .context -}} {{- $context := .context -}}
{{- $disableSidebar := .disableSidebar | default false -}} {{- $disableSidebar := .disableSidebar | default false -}}
{{- $sidebarClass := cond $disableSidebar "md:hidden xl:block" "md:sticky" -}} {{- $displayPlaceholder := .displayPlaceholder | default false -}}
{{- $sidebarClass := cond $disableSidebar (cond $displayPlaceholder "md:hidden xl:block" "md:hidden") "md:sticky" -}}
{{- $navRoot := cond (eq site.Home.Type "docs") site.Home $context.FirstSection -}} {{- $navRoot := cond (eq site.Home.Type "docs") site.Home $context.FirstSection -}}
{{- $navPages := union $navRoot.RegularPages $navRoot.Sections -}} {{- $navPages := union $navRoot.RegularPages $navRoot.Sections -}}
@ -20,8 +23,8 @@
</ul> </ul>
<!-- Sidebar on large screen --> <!-- Sidebar on large screen -->
{{- if $disableSidebar }} {{- if $disableSidebar -}}
<div class="max-xl:hidden h-0 w-64 shrink-0"></div> {{- if $displayPlaceholder }}<div class="max-xl:hidden h-0 w-64 shrink-0"></div>{{ end -}}
{{ .context.Scratch.Set "enableFooterSwitches" true }} {{ .context.Scratch.Set "enableFooterSwitches" true }}
{{- else -}} {{- else -}}
<ul class="flex flex-col gap-1 max-md:hidden"> <ul class="flex flex-col gap-1 max-md:hidden">