Add hook to put content at end of head and body
All Reveal params to be configured at default, site and page levels
This commit is contained in:
parent
9ba8adc268
commit
13d0faf629
10
README.md
10
README.md
|
@ -108,15 +108,15 @@ This is my second slide.
|
|||
|
||||
## Usage
|
||||
|
||||
The Usage guide is contained in the example presentation that lives in this repository at `exampleSite`. You can access a live version at [https://dzello.com/reveal-hugo/](https://dzello.com/reveal-hugo/).
|
||||
The Usage guide is contained in the example presentation that lives in this repository in the [exampleSite](./exampleSite) directory. You can access a live version at [https://dzello.com/reveal-hugo/](https://dzello.com/reveal-hugo/).
|
||||
|
||||
## Configuration
|
||||
|
||||
Customize the Reveal.js presentation by setting these values in `config.toml` or the front matter of any presentation's `index.md`.
|
||||
Customize the Reveal.js presentation by setting these values in `config.toml` or the front matter of any presentation's `index.md` file.
|
||||
|
||||
- `params.reveal_hugo.theme`: The Reveal.js theme used, defaults to "black"
|
||||
|
||||
Include any other attributes in `params.reveal_hugo` that you'd like to be fed as arguments to `Reveal.initialize`. See the [extensive list of options](https://github.com/hakimel/reveal.js/#configuration) here. Defaults used by this theme are located in `data/reveal_hugo.toml`.
|
||||
Include any other attributes in `params.reveal_hugo` that you'd like to be fed as arguments to `Reveal.initialize`. See the [extensive list of Reveal.js configuration options](https://github.com/hakimel/reveal.js/#configuration) here. The defaults used by this theme are located in `data/reveal_hugo.toml`.
|
||||
|
||||
If you're new to TOML, this is how it should look in your `config.toml`:
|
||||
|
||||
|
@ -132,9 +132,9 @@ Or in the front matter of an `_index.md` file:
|
|||
theme = "moon"
|
||||
```
|
||||
|
||||
## Injecting HTML
|
||||
## Adding HTML to the page
|
||||
|
||||
If you need to add something to the HTML page, just override the empty partial that lives at `layouts/partials/reveal-hugo/body.html`. This partial is injected into the page just before the closing of the body tag. Common uses would be to add custom CSS or JS to the page.
|
||||
If you need to add something to the HTML page, just override one or both of the empty partials that live at `layouts/partials/reveal-hugo/body.html` and `layouts/partials/reveal-hugo/head.html`. These partial are injected into the page just before the closing of the body and head tags respectively. Common uses would be to add custom CSS or JavaScript to your presentation.
|
||||
|
||||
### Add a Reveal.js presentation to an existing Hugo site
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
[defaults]
|
||||
theme = 'black'
|
||||
controls = true
|
||||
progress = true
|
||||
history = true
|
||||
|
|
|
@ -3,6 +3,7 @@ title = "Example of a section presentation"
|
|||
outputs = ["Reveal"]
|
||||
[reveal_hugo]
|
||||
theme = "moon"
|
||||
slideNumber = true
|
||||
+++
|
||||
|
||||
# Section Presentation
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<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="{{ "reveal/css/reveal.css" | relURL }}">
|
||||
{{ $theme := or .Page.Params.reveal_hugo.theme .Site.Params.reveal_hugo.theme "black" }}
|
||||
{{ $theme := or .Page.Params.reveal_hugo.theme .Site.Params.reveal_hugo.theme .Site.Data.reveal_hugo.theme "black" }}
|
||||
<link rel="stylesheet" href="{{ printf "reveal/css/theme/%s.css" $theme | relURL }}" id="theme">
|
||||
<!-- Theme used for syntax highlighting of code -->
|
||||
<link rel="stylesheet" href="{{ "reveal/lib/css/zenburn.css" | relURL }}">
|
||||
|
@ -24,13 +24,15 @@
|
|||
<!--[if lt IE 9]>
|
||||
<script src="{{ "reveal/lib/js/html5shiv.js" | relURL }}"></script>
|
||||
<![endif]-->
|
||||
{{ partial "reveal-hugo/head" . }}
|
||||
</head>
|
||||
<body>
|
||||
{{ block "main" . }}{{ end }}
|
||||
<script type="application/json" id="reveal-hugo-params">{{ jsonify .Site.Params.reveal_hugo | safeJS }}</script>
|
||||
<script type="application/json" id="reveal-hugo-page-params">{{ jsonify .Page.Params.reveal_hugo | safeJS }}</script>
|
||||
<script type="application/json" id="reveal-hugo-site-params">{{ jsonify .Site.Params.reveal_hugo | safeJS }}</script>
|
||||
<script type="application/json" id="reveal-hugo-defaults">{{ jsonify .Site.Data.reveal_hugo.defaults | safeJS }}</script>
|
||||
<script type="text/javascript">
|
||||
window.revealDependencies = {
|
||||
window.revealHugoDependencies = {
|
||||
dependencies: [
|
||||
{ src: '{{ "reveal/lib/js/classList.js" | relURL }}', condition: function() { return !document.body.classList; } },
|
||||
{ src: '{{ "reveal/plugin/markdown/marked.js" | relURL }}', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
|
||||
|
|
|
@ -1 +1 @@
|
|||
<!-- override this partial to add content before the body closing -->
|
||||
<!-- override this partial to add content before the body tag closes -->
|
|
@ -0,0 +1 @@
|
|||
<!-- override this partial to add content before the head tag closes -->
|
|
@ -1,6 +1,11 @@
|
|||
// pattern inspired by https://github.com/RealOrangeOne/hugo-theme-revealjs
|
||||
var revealParams = JSON.parse(document.getElementById('reveal-hugo-params').innerHTML);
|
||||
var revealDefaults = JSON.parse(document.getElementById('reveal-hugo-defaults').innerHTML);
|
||||
var revealHugoPageParams = JSON.parse(document.getElementById('reveal-hugo-page-params').innerHTML);
|
||||
var revealHugoSiteParams = JSON.parse(document.getElementById('reveal-hugo-site-params').innerHTML);
|
||||
var revealHugoDefaults = JSON.parse(document.getElementById('reveal-hugo-defaults').innerHTML);
|
||||
|
||||
// More info https://github.com/hakimel/reveal.js#configuration
|
||||
Reveal.initialize(Object.assign(revealDefaults, revealParams, revealDependencies));
|
||||
// See all options - https://github.com/hakimel/reveal.js#configuration
|
||||
Reveal.initialize(Object.assign(
|
||||
revealHugoDefaults,
|
||||
revealHugoSiteParams,
|
||||
revealHugoPageParams,
|
||||
revealHugoDependencies));
|
||||
|
|
Loading…
Reference in New Issue