source ⟩ hypertext ⟩ public ⟩ codex ⟩ codex.pug

extends ../../views/layout.pug

append presets
	- hasSidenotes = true
	- hasComments = false
	- let rawSiteName = tr('codex.siteName');
	- siteName = `${rawSiteName} πŸ‡`
	- og = true
	- licence = false
	- thumbnail = false
	- description = false
	- rootAttrs = {class: codexChapters ? "has-chapters" : undefined, "codex-type": "garamond", "codex-theme": "bede"}
	- let chapters = JSON.parse(codexChapters);

append cosmetics
	link(href="/codex/codex.css", rel="stylesheet")
	script(src="/codex/codex-themer.js")

mixin indexLink
	a(href="/codex")= rawSiteName

mixin backAndForth
	ul.simple-back-forward
		if codexLast
			li: a(href=`/${codexLast}`)
				span ←
				span= codexLastTitle
		else
			li
		li.title
			strong= title.replace(/.*? \| /g, "")
			small #{codexAuthor}, #{grimm.date.ce(lang, pageCreated, 1)}
		if codexNext
			li: a(href=`/${codexNext}`)
				span= codexNextTitle
				span β†’
		else
			li

mixin allChapters
	ul.all-chapters
		each chapter in chapters
			if chapter.link
				li: a(href=`/${chapter.link}`)= chapter.shortName
			else
				li.current: strong= chapter.shortName

prepend container
	if codexChapters
		nav.chapter-select
			+indexLink
			+backAndForth
			+allChapters

append container
	if codexChapters
		nav.chapter-select
			+allChapters
			+backAndForth
			+indexLink

block footer
	if (!codexChapters)
		footer.page-footer
			a(href="/codex") ← #{tr('codex.codexIndex')}