From 516eeca8536b36b65c76ca1d3a46e90cdabf2557 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Tue, 3 May 2022 10:43:22 -0400 Subject: [PATCH] cfg: make SPA optional --- assets/js/search.js | 3 ++- data/config.yaml | 1 + layouts/partials/backlinks.html | 1 + layouts/partials/graph.html | 11 +++++++++++ layouts/partials/head.html | 4 ++++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/assets/js/search.js b/assets/js/search.js index 56ce1b0a..f124d582 100644 --- a/assets/js/search.js +++ b/assets/js/search.js @@ -35,6 +35,7 @@ const removeMarkdown = ( .replace(/<[^>]*>/g, '') .replace(/^[=\-]{2,}\s*$/g, '') .replace(/\[\^.+?\](\: .*?$)?/g, '') + .replace(/(#{1,6})\s+(.+)\1?/g, '$2') .replace(/\s{0,2}\[.*?\]: .*?$/g, '') .replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g, options.useImgAltText ? '$1' : '') .replace(/\[(.*?)\][\[\(].*?[\]\)]/g, '$1') @@ -143,7 +144,7 @@ const removeMarkdown = ( // SPA navigation window.navigate( new URL( - `${BASE_URL.slice(0, -1)}${id}#:~:text=${encodeURIComponent(term)}/` + `${BASE_URL}${id}#:~:text=${encodeURIComponent(term)}/` ), '.singlePage' ) diff --git a/data/config.yaml b/data/config.yaml index e33c3293..afa531c3 100644 --- a/data/config.yaml +++ b/data/config.yaml @@ -3,6 +3,7 @@ enableToc: true openToc: false enableLinkPreview: true enableLatex: true +enableSPA: false description: Host your second brain and digital garden for free. Quartz features extremely fast full-text search, Wikilink support, backlinks, local graph, tags, and link previews. diff --git a/layouts/partials/backlinks.html b/layouts/partials/backlinks.html index deb82e82..e42351ad 100644 --- a/layouts/partials/backlinks.html +++ b/layouts/partials/backlinks.html @@ -10,6 +10,7 @@ {{$cleanedInbound := apply (apply $inbound "index" "." "source") "replace" "." " " "-"}} {{- range $cleanedInbound | uniq -}} {{$l := printf "%s%s/" $host .}} + {{$l = cond (eq $l "//") "/" $l}} {{with (index $contentTable .)}}
  • {{index (index . "title")}} diff --git a/layouts/partials/graph.html b/layouts/partials/graph.html index b9f79763..b8b2f616 100644 --- a/layouts/partials/graph.html +++ b/layouts/partials/graph.html @@ -16,3 +16,14 @@ {{ $js := resources.Get "js/graph.js" | resources.Fingerprint "md5" }} + diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 1dabaf66..37938a55 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -58,6 +58,7 @@ content, })) + {{if $.Site.Data.config.enableSPA}} + {{else}} + + {{end}} {{ template "_internal/google_analytics.html" . }}