-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: first shot of supporting gist (#76)
close #72
- Loading branch information
1 parent
7aa0834
commit fe48519
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
doctype html | ||
html | ||
head | ||
title= title | ||
link(rel='stylesheet', href=`/css/reveal.css`) | ||
link(rel='stylesheet', href=`/css/theme/${theme || 'black'}.css`)#theme | ||
link(rel='stylesheet', href=`/lib/css/zenburn.css`) | ||
link(rel='stylesheet', href='https://cdn.rawgit.com/knsv/mermaid/7.0.0/dist/mermaid.css') | ||
script(src='https://cdn.rawgit.com/knsv/mermaid/7.0.0/dist/mermaid.min.js') | ||
script(src='https://cdn.rawgit.com/mathiasbynens/he/670991a4/he.js') | ||
if printPdf | ||
script. | ||
var link = document.createElement( 'link' ); | ||
link.rel = 'stylesheet'; | ||
link.type = 'text/css'; | ||
link.href = window.location.search.match( /print-pdf/gi ) ? '/css/print/pdf.css' : '/css/print/paper.css'; | ||
document.getElementsByTagName( 'head' )[0].appendChild( link ); | ||
|
||
body | ||
.reveal | ||
.slides | ||
section(data-markdown=url) | ||
|
||
script(src=`/lib/js/head.min.js`) | ||
script(src=`/js/reveal.js`) | ||
script. | ||
// https://github.com/hakimel/reveal.js#configuration | ||
Reveal.initialize({ | ||
controls: true, | ||
progress: true, | ||
history: true, | ||
center: true, | ||
|
||
transition: '#{transition || "slide"}', // none/fade/slide/convex/concave/zoom | ||
|
||
// Optional reveal.js plugins | ||
dependencies: [ | ||
{ src: `/plugin/markdown/marked.js`, async: true }, | ||
{ src: `/plugin/markdown/markdown.js`, async: true }, | ||
{ src: `/lib/js/classList.js`, condition: function() { return !document.body.classList; } }, | ||
{ src: `/plugin/highlight/highlight.js`, async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, | ||
{ src: `/plugin/zoom-js/zoom.js`, async: true }, | ||
{ src: `/plugin/notes/notes.js`, async: true } | ||
] | ||
}); | ||
var nextId = 0; | ||
function onReadyToRenderMermaid(event) { | ||
var mermaidContainer = event.currentSlide.getElementsByClassName('mermaid')[0]; | ||
if (!mermaidContainer) return; | ||
if (mermaidContainer.getAttribute('data-processed')) return; | ||
mermaidContainer.setAttribute('data-processed', true); | ||
var text = he.decode(mermaidContainer.innerHTML).trim(); | ||
|
||
var chart = document.createElement('div'); | ||
mermaidContainer.appendChild(chart); | ||
function insertSvg(svgCode, bindFunctions) { | ||
chart.innerHTML = svgCode; | ||
chart.firstChild.style.width = chart.getAttribute('viewbox').split(' ')[2] + 'px'; | ||
chart.firstChild.style.height = chart.getAttribute('viewbox').split(' ')[3] + 'px'; | ||
bindFunctions(chart); | ||
} | ||
if (!chart.id) { | ||
chart.id = 'mermaidChart' + nextId++; | ||
mermaidAPI.render(chart.id, text, insertSvg, mermaidContainer); | ||
} | ||
Reveal.layout(); | ||
} | ||
Reveal.addEventListener('ready', onReadyToRenderMermaid); | ||
Reveal.addEventListener('slidechanged', onReadyToRenderMermaid); | ||
mermaid.initialize({startOnLoad: false}); | ||
document.addEventListener('keypress', function (event) { | ||
if (typeof URL === 'undefined') return; | ||
const url = new URL(document.location); | ||
if (!url.searchParams) return; | ||
if (event.keyCode === 116) { | ||
const themes = [ | ||
'beige', 'black', 'blood', 'league', 'moon', 'night', 'serif', 'simple', 'sky', 'solarized', 'white' | ||
]; | ||
const prevTheme = url.searchParams.get('theme'); | ||
const prevIndex = themes.indexOf(prevTheme || 'black'); | ||
url.searchParams.set('theme', themes[(prevIndex + 1) % themes.length]); | ||
document.location = url.href; | ||
} | ||
}, false); |