Skip to content

Commit

Permalink
fix(tooling): fix math in multipage layout (#1187)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias authored Sep 30, 2020
1 parent 8bf3e43 commit 335a8a3
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 75 deletions.
27 changes: 16 additions & 11 deletions assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ function initTableSort () {
function initTocDepthSlider () {
var slider = document.getElementById('toc-depth-slider')
var toc = document.querySelector('.toc')

slider.addEventListener('change', (event) => {
handleSliderChange(Number(event.target.value))
})

if(slider) {
slider.addEventListener('change', (event) => {
handleSliderChange(Number(event.target.value))
})
// init to the current value
handleSliderChange(slider.value)
}

function handleSliderChange (depth) {
for (let i = 0; i < 6; i++) {
Expand All @@ -33,15 +37,16 @@ function initTocDepthSlider () {
})
}
}
// init to the current value
handleSliderChange(slider.value)
}

function initTocScrollSpy () {
var spy = new Gumshoe('.toc a', {
nested: true,
nestedClass: 'active-parent'
})
const toc = document.querySelector('.toc a')
if(toc) {
new Gumshoe('.toc a', {
nested: true,
nestedClass: 'active-parent'
})
}
}

window.addEventListener('DOMContentLoaded', () => {
Expand All @@ -50,7 +55,7 @@ window.addEventListener('DOMContentLoaded', () => {
initTableSort()
lightbox()
// load katex when math-mode page intersect with the viewport
let observer = new IntersectionObserver((entries, observer) => {
let observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if(entry.isIntersecting){
renderKatex(entry.target)
Expand Down
13 changes: 6 additions & 7 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<html lang="{{ .Site.Language.Lang }}" dir={{ .Site.Language.LanguageDirection }}>

<head>
{{ partial "docs/html-head" . }}
{{ partial "docs/inject/head" . }}
{{ partial "html-head" . }}
</head>

<body dir={{ .Site.Language.LanguageDirection }}>
Expand All @@ -28,8 +27,6 @@
{{ partial "docs/inject/footer" . }}
</footer>

{{ template "comments" . }} <!-- Comments block -->

<label for="menu-control" class="hidden book-menu-overlay"></label>
</div>

Expand All @@ -46,7 +43,7 @@
{{ end }}
</main>

{{ partial "docs/inject/body" . }}
{{ partial "body" . }}
</body>

</html>
Expand Down Expand Up @@ -78,9 +75,11 @@
{{ end }}

{{ define "main" }}
<article class="markdown">
<article class="markdown {{ if default false (index .Params "math-mode") }}math-mode{{ end }}">
{{- if eq .Title "Home" -}}
{{ with .GetPage "/intro" }}{{ .Content }}{{end}}
{{ with .GetPage "/intro" }}
{{ .Content }}
{{end}}
{{- else -}}
{{- .Content -}}
{{- end -}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

{{ if ne .Site.IsServer true }}
<pwa-update swpath="{{ "/sw.js" | relURL }}" ></pwa-update>
{{end}}
{{end}}
41 changes: 0 additions & 41 deletions layouts/partials/docs/html-head.html

This file was deleted.

10 changes: 0 additions & 10 deletions layouts/partials/docs/inject/body.html

This file was deleted.

File renamed without changes.
10 changes: 5 additions & 5 deletions layouts/single/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="{{ .Site.Language.Lang }}" dir={{ .Site.Language.LanguageDirection }}>

<head>
{{ partial "single/html-head" . }}
{{ partial "html-head" . }}
</head>

<body dir={{ .Site.Language.LanguageDirection }}>
Expand All @@ -11,7 +11,7 @@
<header class="book-header">
{{ template "header" . }} <!-- Mobile layout header -->
</header>

<aside class="book-menu">
{{ template "menu" . }} <!-- Left menu Content -->
</aside>
Expand All @@ -27,9 +27,9 @@

</div>
</main>

<label for="menu-control" class="hidden book-menu-overlay"></label>
{{ partial "single/inject/body" . }}
{{ partial "body" . }}
</script>
</body>

Expand Down Expand Up @@ -79,4 +79,4 @@
{{ end }}
{{- template "mainChildren" (dict "Section" . ) -}}
{{ end }}
{{ end }}
{{ end }}

0 comments on commit 335a8a3

Please sign in to comment.