Skip to content

Commit

Permalink
cfg: make SPA optional
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyzha0 committed May 3, 2022
1 parent fc89ff2 commit 24d08d5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion assets/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const removeMarkdown = (
.replace(/<[^>]*>/g, '')
.replace(/^[=\-]{2,}\s*$/g, '')
.replace(/\[\^.+?\](\: .*?$)?/g, '')
.replace(/(#{1,6})\s+(.+)\1?/g, '<b>$2</b>')
.replace(/\s{0,2}\[.*?\]: .*?$/g, '')
.replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g, options.useImgAltText ? '$1' : '')
.replace(/\[(.*?)\][\[\(].*?[\]\)]/g, '$1')
Expand Down Expand Up @@ -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'
)
Expand Down
1 change: 1 addition & 0 deletions data/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions layouts/partials/backlinks.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ <h3>Backlinks</h3>
{{$cleanedInbound := apply (apply $inbound "index" "." "source") "replace" "." " " "-"}}
{{- range $cleanedInbound | uniq -}}
{{$l := printf "%s%s/" $host .}}
{{$l = cond (eq $l "//") "/" $l}}
{{with (index $contentTable .)}}
<li>
<a href="{{$l}}">{{index (index . "title")}}</a>
Expand Down
11 changes: 11 additions & 0 deletions layouts/partials/graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,14 @@ <h3>Interactive Graph</h3>
</style>
{{ $js := resources.Get "js/graph.js" | resources.Fingerprint "md5" }}
<script src="{{ $js.Permalink }}"></script>
<script>
drawGraph(
{{strings.TrimRight "/" .Page.Permalink}},
{{strings.TrimRight "/" .Site.BaseURL}},
{{$.Site.Data.graphConfig.paths}},
{{$.Site.Data.graphConfig.depth}},
{{$.Site.Data.graphConfig.enableDrag}},
{{$.Site.Data.graphConfig.enableLegend}},
{{$.Site.Data.graphConfig.enableZoom}}
);
</script>
4 changes: 4 additions & 0 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
content,
}))
</script>
{{if $.Site.Data.config.enableSPA}}
<script type="module">
import { router, navigate } from "https://unpkg.com/million/dist/router.mjs";
// SPA navigation for access later
Expand Down Expand Up @@ -89,5 +90,8 @@
window.addEventListener("million:navigate", callback);
window.addEventListener("DOMContentLoaded", callback);
</script>
{{else}}
<script>window.navigate = (url) => window.location.href = url</script>
{{end}}
</head>
{{ template "_internal/google_analytics.html" . }}

0 comments on commit 24d08d5

Please sign in to comment.