Add margin notes: Tufte-style side notes with dashed inline fallback
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
<script>
|
||||
// 让 CSS 知道 JS 可用:宽屏边注需要 JS 定位
|
||||
document.documentElement.classList.add("js");
|
||||
</script>
|
||||
<script defer src="/js/notes.js"></script>
|
||||
<!-- Expand sidebar tree by default -->
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
{{ define "main" }}
|
||||
<div class="hx:mx-auto hx:flex hextra-max-page-width">
|
||||
{{- /* 有边注的页面:宽屏两侧需要留白,因此去掉 TOC 与侧栏占位 */ -}}
|
||||
{{- $hasNotes := .HasShortcode "note" }}
|
||||
<div class="hx:mx-auto hx:flex hextra-max-page-width{{ if $hasNotes }} has-notes{{ end }}">
|
||||
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true
|
||||
"displayPlaceholder" true) }} {{ partial "toc.html" . }}
|
||||
"displayPlaceholder" (not $hasNotes)) }} {{ if not $hasNotes }}{{ partial
|
||||
"toc.html" . }}{{ end }}
|
||||
<article
|
||||
class="hx:w-full hx:break-words hx:flex hx:min-h-[calc(100vh-var(--navbar-height))] hx:min-w-0 hx:justify-center hx:pb-8 hx:pr-[calc(env(safe-area-inset-right)-1.5rem)]"
|
||||
>
|
||||
<main
|
||||
id="content"
|
||||
class="hx:w-full hx:min-w-0 hextra-max-content-width hx:px-6 hx:pt-0 hx:md:px-12"
|
||||
class="hx:w-full hx:min-w-0 hextra-max-content-width hx:px-6 hx:pt-0 hx:md:px-12{{ if $hasNotes }} notes-page{{ end }}"
|
||||
>
|
||||
{{ partial "breadcrumb.html" (dict "page" . "enable" true) }} {{ if
|
||||
.Title }}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{{- /*
|
||||
边注 / 注释。
|
||||
宽屏:显示在正文两侧的空白处(由 static/js/notes.js 定位)。
|
||||
窄屏:以虚线框内嵌在文章中。
|
||||
用法:{{< note >}}注释内容{{< /note >}}
|
||||
*/ -}}
|
||||
{{- $n := add (.Page.Store.Get "noteCount" | default 0) 1 -}}
|
||||
{{- .Page.Store.Set "noteCount" $n -}}
|
||||
<sup class="post-note-mark">{{ $n }}</sup><span class="post-note" data-note="{{ $n }}">{{- .Inner | .Page.RenderString (dict "display" "inline") -}}</span>
|
||||
Reference in New Issue
Block a user