Add router
parent
416dc0b85c
commit
bcb166c21c
@ -1,46 +1,87 @@
|
|||||||
<head>
|
<head>
|
||||||
<!-- Meta tags -->
|
<!-- Meta tags -->
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8" />
|
||||||
<meta name="description" content="{{if .IsHome}}{{$.Site.Data.config.description}}{{else}}{{.Summary}}{{end}}">
|
<meta
|
||||||
<title>{{ if .Title }}{{ .Title }}{{ else }}{{ $.Site.Data.config.page_title }}{{ end }}</title>
|
name="description"
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
content="{{if .IsHome}}{{$.Site.Data.config.description}}{{else}}{{.Summary}}{{end}}"
|
||||||
<link rel="shortcut icon" type="image/png" href="{{$.Site.BaseURL}}/icon.png" />
|
/>
|
||||||
|
<title>
|
||||||
|
{{ if .Title }}{{ .Title }}{{ else }}{{ $.Site.Data.config.page_title }}{{
|
||||||
|
end }}
|
||||||
|
</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<link
|
||||||
|
rel="shortcut icon"
|
||||||
|
type="image/png"
|
||||||
|
href="{{$.Site.BaseURL}}/icon.png"
|
||||||
|
/>
|
||||||
|
|
||||||
<!-- CSS Stylesheets and Fonts -->
|
<!-- CSS Stylesheets and Fonts -->
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Source+Sans+Pro:wght@400;600;700&family=Fira+Code:wght@400;700&display=swap" rel="stylesheet">
|
<link
|
||||||
{{$sass := resources.Match "styles/[!_]*.scss" }}
|
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Source+Sans+Pro:wght@400;600;700&family=Fira+Code:wght@400;700&display=swap"
|
||||||
{{$css := slice }}
|
rel="stylesheet"
|
||||||
{{range $sass}}
|
/>
|
||||||
{{$scss := . | resources.ToCSS (dict "outputStyle" "compressed") }}
|
{{$sass := resources.Match "styles/[!_]*.scss" }} {{$css := slice }} {{range
|
||||||
{{$css = $css | append $scss}}
|
$sass}} {{$scss := . | resources.ToCSS (dict "outputStyle" "compressed") }}
|
||||||
{{end}}
|
{{$css = $css | append $scss}} {{end}} {{$finalCss := $css | resources.Concat
|
||||||
{{$finalCss := $css | resources.Concat "styles.css" | resources.Fingerprint "md5" | resources.Minify }}
|
"styles.css" | resources.Fingerprint "md5" | resources.Minify }}
|
||||||
<link href="{{$finalCss.Permalink}}" rel="stylesheet">
|
<link href="{{$finalCss.Permalink}}" rel="stylesheet" />
|
||||||
|
|
||||||
{{ $darkMode := resources.Get "js/darkmode.js" | resources.Fingerprint "md5" | resources.Minify }}
|
{{ $darkMode := resources.Get "js/darkmode.js" | resources.Fingerprint "md5" |
|
||||||
<script src="{{$darkMode.Permalink}}"></script>
|
resources.Minify }}
|
||||||
{{partial "katex.html" .}}
|
<script src="{{$darkMode.Permalink}}"></script>
|
||||||
|
{{partial "katex.html" .}}
|
||||||
|
|
||||||
<!-- Preload page vars -->
|
<!-- Preload page vars -->
|
||||||
{{$linkIndex := resources.Get "indices/linkIndex.json" | resources.Fingerprint "md5" | resources.Minify | }}
|
{{$linkIndex := resources.Get "indices/linkIndex.json" | resources.Fingerprint
|
||||||
{{$contentIndex := resources.Get "indices/contentIndex.json" | resources.Fingerprint "md5" | resources.Minify }}
|
"md5" | resources.Minify | }} {{$contentIndex := resources.Get
|
||||||
<script>
|
"indices/contentIndex.json" | resources.Fingerprint "md5" | resources.Minify
|
||||||
const BASE_URL = {{.Site.BaseURL}}
|
}}
|
||||||
const fetchData = Promise.all([
|
<script>
|
||||||
fetch("{{ $linkIndex.Permalink }}")
|
const BASE_URL = {{.Site.BaseURL}}
|
||||||
.then(data => data.json())
|
const fetchData = Promise.all([
|
||||||
.then(data => ({
|
fetch("{{ $linkIndex.Permalink }}")
|
||||||
index: data.index,
|
.then(data => data.json())
|
||||||
links: data.links,
|
.then(data => ({
|
||||||
})),
|
index: data.index,
|
||||||
fetch("{{ $contentIndex.Permalink }}")
|
links: data.links,
|
||||||
.then(data => data.json()),
|
})),
|
||||||
])
|
fetch("{{ $contentIndex.Permalink }}")
|
||||||
.then(([{index, links}, content]) => ({
|
.then(data => data.json()),
|
||||||
index,
|
])
|
||||||
links,
|
.then(([{index, links}, content]) => ({
|
||||||
content,
|
index,
|
||||||
}))
|
links,
|
||||||
</script>
|
content,
|
||||||
|
}))
|
||||||
|
</script>
|
||||||
|
<script type="module">
|
||||||
|
import { router, navigate } from "https://unpkg.com/million/dist/router.mjs";
|
||||||
|
window.navigate = navigate;
|
||||||
|
router(".singlePage");
|
||||||
|
const callback = () => {
|
||||||
|
const draw = () => {
|
||||||
|
const container = document.getElementById("graph-container");
|
||||||
|
// retry if the graph is not ready
|
||||||
|
if (!container) return requestAnimationFrame(draw);
|
||||||
|
// clear the graph in case there is anything within it
|
||||||
|
container.textContent = "";
|
||||||
|
|
||||||
|
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}}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
requestAnimationFrame(draw);
|
||||||
|
};
|
||||||
|
// We need on initial load, then subsequent redirs
|
||||||
|
window.addEventListener("million:navigate", callback);
|
||||||
|
window.addEventListener("DOMContentLoaded", callback);
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
{{ template "_internal/google_analytics.html" . }}
|
{{ template "_internal/google_analytics.html" . }}
|
||||||
|
Loading…
Reference in New Issue