fix(code titles): fixed code titles with and without SPA

This commit is contained in:
Geoffrey Garrett 2022-06-29 22:39:01 +02:00
parent 8fdc927bab
commit a3ddb1bde7

View File

@ -76,12 +76,13 @@
const render = () => {
// NOTE: everything within this callback will be executed for every page navigation. This is a good place to put JavaScript that loads or modifies data on the page, adds event listeners, etc. If you are only dealing with basic DOM replacement, use the init function
const siteBaseURL = new URL({{$.Site.BaseURL}});
const pathBase = siteBaseURL.pathname;
const pathWindow = window.location.pathname;
const isHome = pathBase == pathWindow;
{{if $.Site.Data.config.enableFooter}}
const container = document.getElementById("graph-container")
// retry if the graph is not ready
@ -99,9 +100,6 @@
{{end}}
{{if $.Site.Data.config.enableCodeBlockTitle -}}
addTitleToCodeBlocks();
{{- end -}}
{{if $.Site.Data.config.enableLinkPreview}}
initPopover(
@ -114,6 +112,13 @@
const init = (doc = document) => {
// NOTE: everything within this callback will be executed for initial page navigation. This is a good place to put JavaScript that only replaces DOM nodes.
{{if $.Site.Data.config.enableCodeBlockTitle -}}
{{if $.Site.Data.config.enableSPA -}}
addTitleToCodeBlocks();
{{ else }}
window.addEventListener("DOMContentLoaded", addTitleToCodeBlocks);
{{- end -}}
{{- end -}}
{{if $.Site.Data.config.enableLatex}}
renderMathInElement(doc.body, {
delimiters: [