mirror of
https://github.com/Threnklyn/reveal-hugo.git
synced 2026-05-18 21:03:29 +02:00
Create partials from layout sections for easier overriding
This commit is contained in:
@@ -1,32 +1,8 @@
|
||||
<!doctype html>
|
||||
{{- $reveal_location := $.Param "reveal_hugo.reveal_cdn" | default "reveal-js" -}}
|
||||
{{- $highlight_location := $.Param "reveal_hugo.highlight_cdn" | default "highlight-js" -}}
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{{ or .Page.Title .Site.Title }}</title>
|
||||
{{ with $.Param "description" }}<meta name="description" content="{{ . }}">{{ end }}
|
||||
{{ with .Site.Author.name }}<meta name="author" content="{{ . }}">{{ end }}
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<link rel="stylesheet" href="{{ printf "%s/css/reveal.css" $reveal_location | relURL }}">
|
||||
<!-- Theme used for presentation -->
|
||||
{{- $custom_theme := $.Param "reveal_hugo.custom_theme" -}}
|
||||
{{- if $custom_theme -}}
|
||||
{{- if $.Param "reveal_hugo.custom_theme_compile" -}}
|
||||
{{ $asset := resources.Get $custom_theme | toCSS | minify | fingerprint }}
|
||||
<link rel="stylesheet" href="{{ $asset.Permalink }}" id="theme">
|
||||
{{- else -}}
|
||||
<link rel="stylesheet" href="{{ $custom_theme | relURL }}" id="theme">
|
||||
{{- end -}}
|
||||
{{ else -}}
|
||||
{{- $theme := $.Param "reveal_hugo.theme" | default "black" -}}
|
||||
<link rel="stylesheet" href="{{ printf "%s/css/theme/%s.css" $reveal_location $theme | relURL }}" id="theme">
|
||||
{{ end -}}
|
||||
<!-- Theme used for syntax highlighting of code -->
|
||||
{{- $highlight_theme := $.Param "reveal_hugo.highlight_theme" | default "default" -}}
|
||||
<link rel="stylesheet" href="{{ printf "%s/%s.min.css" $highlight_location $highlight_theme | relURL }}">
|
||||
{{ partial "layout/head" . }}
|
||||
{{ partial "layout/theme" . }}
|
||||
<!-- To insert markup before the closing head tag for all presentations,
|
||||
create layouts/partials/reveal-hugo/head.html -->
|
||||
{{- partial "reveal-hugo/head" . -}}
|
||||
@@ -48,57 +24,7 @@
|
||||
{{- $sectionHeadPartial := printf "%s/reveal-hugo/end" (.Page.Section | default "home") -}}
|
||||
{{- if fileExists (printf "layouts/partials/%s.html" $sectionHeadPartial) -}}{{ partial $sectionHeadPartial . }}{{- end }}
|
||||
</div>
|
||||
<!-- Printing and PDF exports -->
|
||||
<!-- use Hugo to create the right path for the print stylesheet, then conditionally include it -->
|
||||
<a href="{{ printf "%s/css/print/" $reveal_location | relURL }}" id="print-location" style="display: none;">
|
||||
<script type="text/javascript">
|
||||
var printLocationElement = document.getElementById('print-location');
|
||||
var link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.type = 'text/css';
|
||||
link.href = printLocationElement.href + (window.location.search.match(/print-pdf/gi) ? 'pdf.css' : 'paper.css');
|
||||
document.getElementsByTagName('head')[0].appendChild(link);
|
||||
</script>
|
||||
<!-- output Hugo parameters into JavaScript to be used when initializing Reveal.js -->
|
||||
<script type="application/json" id="reveal-hugo-site-params">{{ jsonify .Site.Params.reveal_hugo | safeJS }}</script>
|
||||
<script type="application/json" id="reveal-hugo-page-params">{{ jsonify .Page.Params.reveal_hugo | safeJS }}</script>
|
||||
<!-- load Reveal.js javascripts -->
|
||||
<script src="{{ printf "%s/lib/js/head.min.js" $reveal_location | relURL }}"></script>
|
||||
<script src="{{ printf "%s/js/reveal.js" $reveal_location | relURL }}"></script>
|
||||
<!-- load Reveal.js plugins -->
|
||||
<script type="text/javascript" src="{{ printf "%s/plugin/markdown/marked.js" $reveal_location | relURL }}"></script>
|
||||
<script type="text/javascript" src="{{ printf "%s/plugin/markdown/markdown.js" $reveal_location | relURL }}"></script>
|
||||
<script type="text/javascript" src="{{ printf "%s/plugin/highlight/highlight.js" $reveal_location | relURL }}"></script>
|
||||
<script type="text/javascript" src="{{ printf "%s/plugin/zoom-js/zoom.js" $reveal_location | relURL }}"></script>
|
||||
<!-- always use local version of the notes plugin since HTML file it requires isn't on CDN -->
|
||||
<script type="text/javascript" src="{{ "reveal-js/plugin/notes/notes.js" | relURL }}"></script>
|
||||
<script type="text/javascript">
|
||||
// Hugo lowercases all params and Reveal.js needs camelcase
|
||||
// So params in Hugo must be stored in snakecase and we camelize them here
|
||||
function camelize(map) {
|
||||
if (map) {
|
||||
Object.keys(map).forEach(function(k) {
|
||||
newK = k.replace(/(\_\w)/g, function(m) { return m[1].toUpperCase() });
|
||||
if (newK != k) {
|
||||
map[newK] = map[k];
|
||||
delete map[k];
|
||||
}
|
||||
});
|
||||
}
|
||||
return map;
|
||||
}
|
||||
// pattern inspired by https://github.com/RealOrangeOne/hugo-theme-revealjs
|
||||
var revealHugoDefaults = { center: true, controls: true, history: true, progress: true, transition: "slide" };
|
||||
var revealHugoSiteParams = JSON.parse(document.getElementById('reveal-hugo-site-params').innerHTML);
|
||||
var revealHugoPageParams = JSON.parse(document.getElementById('reveal-hugo-page-params').innerHTML);
|
||||
// See all options - https://github.com/hakimel/reveal.js#configuration
|
||||
var options = Object.assign({},
|
||||
camelize(revealHugoDefaults),
|
||||
camelize(revealHugoSiteParams),
|
||||
camelize(revealHugoPageParams));
|
||||
Reveal.initialize(options);
|
||||
hljs.initHighlightingOnLoad();
|
||||
</script>
|
||||
{{- partial "layout/javascript" . }}
|
||||
<!-- To insert markup before the closing body tag for all presentations,
|
||||
create layouts/partials/reveal-hugo/body.html -->
|
||||
{{- partial "reveal-hugo/body" . }}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<meta charset="utf-8">
|
||||
<title>{{ or .Page.Title .Site.Title }}</title>
|
||||
{{ with $.Param "description" }}<meta name="description" content="{{ . }}">{{ end }}
|
||||
{{ with .Site.Author.name }}<meta name="author" content="{{ . }}">{{ end }}
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
@@ -0,0 +1,52 @@
|
||||
<!-- Printing and PDF exports -->
|
||||
<!-- use Hugo to create the right path for the print stylesheet, then conditionally include it -->
|
||||
{{- $reveal_location := $.Param "reveal_hugo.reveal_cdn" | default "reveal-js" -}}
|
||||
<a href="{{ printf "%s/css/print/" $reveal_location | relURL }}" id="print-location" style="display: none;">
|
||||
<script type="text/javascript">
|
||||
var printLocationElement = document.getElementById('print-location');
|
||||
var link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.type = 'text/css';
|
||||
link.href = printLocationElement.href + (window.location.search.match(/print-pdf/gi) ? 'pdf.css' : 'paper.css');
|
||||
document.getElementsByTagName('head')[0].appendChild(link);
|
||||
</script>
|
||||
<!-- output Hugo parameters into JavaScript to be used when initializing Reveal.js -->
|
||||
<script type="application/json" id="reveal-hugo-site-params">{{ jsonify .Site.Params.reveal_hugo | safeJS }}</script>
|
||||
<script type="application/json" id="reveal-hugo-page-params">{{ jsonify .Page.Params.reveal_hugo | safeJS }}</script>
|
||||
<!-- load Reveal.js javascripts -->
|
||||
<script src="{{ printf "%s/lib/js/head.min.js" $reveal_location | relURL }}"></script>
|
||||
<script src="{{ printf "%s/js/reveal.js" $reveal_location | relURL }}"></script>
|
||||
<!-- load Reveal.js plugins -->
|
||||
<script type="text/javascript" src="{{ printf "%s/plugin/markdown/marked.js" $reveal_location | relURL }}"></script>
|
||||
<script type="text/javascript" src="{{ printf "%s/plugin/markdown/markdown.js" $reveal_location | relURL }}"></script>
|
||||
<script type="text/javascript" src="{{ printf "%s/plugin/highlight/highlight.js" $reveal_location | relURL }}"></script>
|
||||
<script type="text/javascript" src="{{ printf "%s/plugin/zoom-js/zoom.js" $reveal_location | relURL }}"></script>
|
||||
<!-- always use local version of the notes plugin since HTML file it requires isn't on CDN -->
|
||||
<script type="text/javascript" src="{{ "reveal-js/plugin/notes/notes.js" | relURL }}"></script>
|
||||
<script type="text/javascript">
|
||||
// Hugo lowercases all params and Reveal.js needs camelcase
|
||||
// So params in Hugo must be stored in snakecase and we camelize them here
|
||||
function camelize(map) {
|
||||
if (map) {
|
||||
Object.keys(map).forEach(function(k) {
|
||||
newK = k.replace(/(\_\w)/g, function(m) { return m[1].toUpperCase() });
|
||||
if (newK != k) {
|
||||
map[newK] = map[k];
|
||||
delete map[k];
|
||||
}
|
||||
});
|
||||
}
|
||||
return map;
|
||||
}
|
||||
// pattern inspired by https://github.com/RealOrangeOne/hugo-theme-revealjs
|
||||
var revealHugoDefaults = { center: true, controls: true, history: true, progress: true, transition: "slide" };
|
||||
var revealHugoSiteParams = JSON.parse(document.getElementById('reveal-hugo-site-params').innerHTML);
|
||||
var revealHugoPageParams = JSON.parse(document.getElementById('reveal-hugo-page-params').innerHTML);
|
||||
// See all options - https://github.com/hakimel/reveal.js#configuration
|
||||
var options = Object.assign({},
|
||||
camelize(revealHugoDefaults),
|
||||
camelize(revealHugoSiteParams),
|
||||
camelize(revealHugoPageParams));
|
||||
Reveal.initialize(options);
|
||||
hljs.initHighlightingOnLoad();
|
||||
</script>
|
||||
@@ -0,0 +1,20 @@
|
||||
<!-- Theme used for presentation -->
|
||||
{{- $reveal_location := $.Param "reveal_hugo.reveal_cdn" | default "reveal-js" -}}
|
||||
{{- $highlight_location := $.Param "reveal_hugo.highlight_cdn" | default "highlight-js" -}}
|
||||
|
||||
<link rel="stylesheet" href="{{ printf "%s/css/reveal.css" $reveal_location | relURL }}">
|
||||
{{- $custom_theme := $.Param "reveal_hugo.custom_theme" -}}
|
||||
{{- if $custom_theme -}}
|
||||
{{- if $.Param "reveal_hugo.custom_theme_compile" -}}
|
||||
{{ $asset := resources.Get $custom_theme | toCSS | minify | fingerprint }}
|
||||
<link rel="stylesheet" href="{{ $asset.Permalink }}" id="theme">
|
||||
{{- else -}}
|
||||
<link rel="stylesheet" href="{{ $custom_theme | relURL }}" id="theme">
|
||||
{{- end -}}
|
||||
{{ else -}}
|
||||
{{- $theme := $.Param "reveal_hugo.theme" | default "black" -}}
|
||||
<link rel="stylesheet" href="{{ printf "%s/css/theme/%s.css" $reveal_location $theme | relURL }}" id="theme">
|
||||
{{ end -}}
|
||||
<!-- Theme used for syntax highlighting of code -->
|
||||
{{- $highlight_theme := $.Param "reveal_hugo.highlight_theme" | default "default" -}}
|
||||
<link rel="stylesheet" href="{{ printf "%s/%s.min.css" $highlight_location $highlight_theme | relURL }}">
|
||||
Reference in New Issue
Block a user