Shortcode overhaul

This commit is contained in:
Zachary Betz 2019-02-12 23:52:29 -06:00
parent 0d0e73dd2f
commit a553a9526f
15 changed files with 235 additions and 88 deletions

View File

@ -46,7 +46,7 @@ TODO link RealFaviconGenerator and give steps
## Shortcodes
TODO list em
TODO link to demo post
## Credits

View File

@ -1,5 +1,6 @@
+++
title = "The Name Of This Project/Site"
+++
---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
tags: []
---
This is your homepage. These are the contents of the `index.md` file, found in your `content` folder.

View File

@ -5,7 +5,6 @@ title = "Cupper"
theme = "cupper-hugo-theme"
googleAnalytics = "UA-123456789-1"
# Uncomment below to enable syntax highlighting
# For more styles see https://xyproto.github.io/splash/docs/all.html
pygmentsCodefences = true
pygmentsStyle = "algol"
@ -20,11 +19,11 @@ pygmentsStyle = "algol"
quality = 99
[params]
# description = "An accessibility-friendly Hugo theme, ported from the [original Cupper](https://github.com/ThePacielloGroup/cupper) project."
description = "An accessibility-friendly Hugo theme, ported from the [original Cupper](https://github.com/ThePacielloGroup/cupper) project."
footer = "Made with [Hugo](https://gohugo.io/). Themed by [Cupper](https://github.com/zwbetz-gh/cupper-hugo-theme). Deployed to [Netlify](https://www.netlify.com/)."
# For more date formats see https://gohugo.io/functions/format/
dateFormat = "Jan 2, 2006"
codePenUser = "TODO"
codePenUser = "someUser"
[menu]
[[menu.nav]]

View File

@ -8,7 +8,7 @@ Welcome to **Cupper**: An accessibility-friendly Hugo theme, ported from the [or
{{% ticks %}}
* Screen reader and keyboard accessible
* Responsive
* Shortcodes for figures, notes, warnings, file trees, and expandable sections -- just to name a few
* Numerous shortcodes
* Toggleable dark theme
* Toggleable table of contents per blog post
{{% /ticks %}}

View File

@ -0,0 +1,213 @@
---
title: "Cupper shortcodes"
date: 2019-02-12T23:39:06-06:00
tags: [hugo]
---
## blockquote
```
{{%/* blockquote author="Carl Jung" */%}}
Even a happy life cannot be without a measure of darkness, and the word happy would lose its meaning if it were not balanced by sadness. It is far better to take things as they come along with patience and equanimity.
{{%/* /blockquote */%}}
```
{{% blockquote author="Carl Jung" %}}
Even a happy life cannot be without a measure of darkness, and the word happy would lose its meaning if it were not balanced by sadness. It is far better to take things as they come along with patience and equanimity.
{{% /blockquote %}}
## cmd
```
{{</* cmd */>}}
hugo server --gc
{{</* /cmd */>}}
```
{{< cmd >}}
hugo server --gc
{{< /cmd >}}
## code
```
{{</* code numbered="true" */>}}
<div [[[role="dialog"]]] [[[aria-labelledby="dialog-heading"]]]>
<button [[[aria-label="close"]]]>x</button>
<h2 [[[id="dialog-heading"]]]>Confirmation</h2>
<p>Press Okay to confirm or Cancel</p>
<button>Okay</button>
<button>Cancel</button>
</div>
{{</* /code */>}}
1. The dialog is only announced as a dialog if it takes the `dialog` ARIA role
2. The `aria-labelledby` relationship attribute makes the element carrying the `id` it points to its label
3. The close button uses `aria-label` to provide the text label "close", overriding the text content
4. The heading is used as the dialog's label. The `aria-labelledby` attribute points to its `id`
```
{{< code numbered="true" >}}
<div [[[role="dialog"]]] [[[aria-labelledby="dialog-heading"]]]>
<button [[[aria-label="close"]]]>x</button>
<h2 [[[id="dialog-heading"]]]>Confirmation</h2>
<p>Press Okay to confirm or Cancel</p>
<button>Okay</button>
<button>Cancel</button>
</div>
{{< /code >}}
1. The dialog is only announced as a dialog if it takes the `dialog` ARIA role
2. The `aria-labelledby` relationship attribute makes the element carrying the `id` it points to its label
3. The close button uses `aria-label` to provide the text label "close", overriding the text content
4. The heading is used as the dialog's label. The `aria-labelledby` attribute points to its `id`
## codePen
```
{{%/* codePen VpVNKW */%}}
```
{{% codePen VpVNKW %}}
## colors
```
{{%/* colors "#111111, #cccccc, #ffffff" */%}}
```
{{% colors "#111111, #cccccc, #ffffff" %}}
## expandable
```
{{%/* expandable label="A section of dummy text" level="2" */%}}
Here is some markdown including [a link](https://twitter.com/heydonworks). Donec erat est, feugiat a est sed, aliquet pharetra ipsum. Vivamus in arcu leo. Praesent feugiat, purus a molestie ultrices, libero massa iaculis ante, sit amet accumsan leo eros vel ligula.
{{%/* /expandable */%}}
```
{{% expandable label="A section of dummy text" level="2" %}}
Here is some markdown including [a link](https://twitter.com/heydonworks). Donec erat est, feugiat a est sed, aliquet pharetra ipsum. Vivamus in arcu leo. Praesent feugiat, purus a molestie ultrices, libero massa iaculis ante, sit amet accumsan leo eros vel ligula.
{{% /expandable %}}
## figure
```
{{</* figure
img="sun.jpg"
caption="The Sun is the star at the center of the Solar System. It is a nearly perfect sphere of hot plasma, with internal convective motion that generates a magnetic field via a dynamo process. It is by far the most important source of energy for life on Earth. [Credits](https://images.nasa.gov/details-GSFC_20171208_Archive_e000393.html)."
command="Resize"
options="700x" */>}}
```
{{< figure
img="sun.jpg"
caption="The Sun is the star at the center of the Solar System. It is a nearly perfect sphere of hot plasma, with internal convective motion that generates a magnetic field via a dynamo process. It is by far the most important source of energy for life on Earth. [Credits](https://images.nasa.gov/details-GSFC_20171208_Archive_e000393.html)."
command="Resize"
options="700x" >}}
## fileTree
```
{{%/* fileTree */%}}
* Level 1 folder
* Level 2 file
* Level 2 folder
* Level 3 file
* Level 3 folder
* Level 4 file
* Level 3 folder
* Level 4 file
* Level 4 file
* Level 3 file
* Level 2 folder
* Level 3 file
* Level 3 file
* Level 3 file
* Level 2 file
* Level 1 file
{{%/* /fileTree */%}}
```
{{% fileTree %}}
* Level 1 folder
* Level 2 file
* Level 2 folder
* Level 3 file
* Level 3 folder
* Level 4 file
* Level 3 folder
* Level 4 file
* Level 4 file
* Level 3 file
* Level 2 folder
* Level 3 file
* Level 3 file
* Level 3 file
* Level 2 file
* Level 1 file
{{% /fileTree %}}
## note
```
{{%/* note */%}}
This is a note! It's something the reader may like to know about but is supplementary to the main content. Use notes when something may be interesting but not critical.
{{%/* /note */%}}
```
{{% note %}}
This is a note! It's something the reader may like to know about but is supplementary to the main content. Use notes when something may be interesting but not critical.
{{% /note %}}
## principles
```
{{%/* principles include="Add value, Be consistent" descriptions="true" */%}}
```
{{% principles include="Add value, Be consistent" descriptions="true" %}}
## tested
```
{{%/* tested using="Firefox + JAWS, Chrome, Safari iOS + Voiceover, Edge" */%}}
```
{{% tested using="Firefox + JAWS, Chrome, Safari iOS + Voiceover, Edge" %}}
## ticks
```
{{%/* ticks */%}}
* Selling point one
* Selling point two
* Selling point three
{{%/* /ticks */%}}
```
{{% ticks %}}
* Selling point one
* Selling point two
* Selling point three
{{% /ticks %}}
## warning
```
{{%/* warning */%}}
This is a warning! It's about something the reader should be careful to do or to avoid doing. Use warnings when something could go wrong.
{{%/* /warning */%}}
```
{{% warning %}}
This is a warning! It's about something the reader should be careful to do or to avoid doing. Use warnings when something could go wrong.
{{% /warning %}}
## wcag
```
{{%/* wcag include="1.2.1, 1.3.1, 4.1.2" */%}}
```
{{% wcag include="1.2.1, 1.3.1, 4.1.2" %}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 MiB

View File

@ -14,5 +14,6 @@
</div>
</div>
{{ partial "script.html" . }}
{{ partial "google-analytics-async.html" . }}
</body>
</html>

View File

@ -0,0 +1,10 @@
{{ if not .Site.IsServer }}
{{ with .Site.GoogleAnalytics }}
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', '{{ . }}', 'auto');
ga('send', 'pageview');
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
{{ end }}
{{ end }}

View File

@ -1 +0,0 @@
<pre class="{{ with .Get "lang" }}language-{{ . }}{{ end }}"><code {{ with .Get "lang" }}class="language-{{ . }}"{{ end }} data-codeblock-shortcode>{{ .Inner }}</code></pre>

View File

@ -1,65 +0,0 @@
{{ $uniq := .Inner | htmlEscape | md5 | lower }}
<div class="demo-container">
{{ if .Get "caption" }}
<figure role="group" aria-labelledby="caption-{{ $uniq }}">
{{ end }}
<div class="demo-inner" {{ if .Get "style" }}style="{{ .Get "style" | safeCSS }}"{{ end }}>
<div class="demo" id="js-demo-{{ $uniq }}"></div>
<button data-launch="js-demo-{{ $uniq }}">Launch <span aria-hidden="true"></span></button>
</div>
{{ if .Get "caption" }}
<figcaption id="caption-{{ $uniq }}">{{ .Get "caption" | markdownify }}</figcaption>
{{ end }}
{{ if .Get "caption" }}
</figure>
{{ end }}
<template id="template-{{ $uniq }}">
{{ .Inner }}
</template>
<script>
(function() {
var root = document.getElementById('js-demo-{{ $uniq }}');
var template = document.getElementById('template-{{ $uniq }}');
// Save a version for the new window
var demoDiv = document.createElement('div');
demoDiv.innerHTML = template.innerHTML;
var standaloneScript = demoDiv.querySelector('script');
if (standaloneScript) {
standaloneScript.textContent = '(function() { document.getElementsByTagName(\'html\')[0].setAttribute(\'lang\', \'en\'); var demo = document; {{ if .Get "style" }}document.body.setAttribute(\'style\', \'{{ .Get "style" | safeCSS }}\'){{ end }}' + standaloneScript.textContent + ' })();';
}
if (document.head.attachShadow) {
var templateScript = template.content.querySelector('script');
if (templateScript) {
var wrappedScript = '(function() { var demo = document.getElementById(\'js-demo-{{ $uniq }}\').shadowRoot;' + templateScript.textContent + '})();';
templateScript.textContent = wrappedScript;
}
root.attachShadow({mode: 'open'});
root.shadowRoot.appendChild(document.importNode(template.content, true));
} else {
root.innerHTML = '<p class="site-error"><strong style="font-weight:bold">Site error:</strong> A browser supporting Shadow DOM is needed to run encapsulated demos. You can launch the demo in a separate window ↓</p>';
}
var launchButton = document.querySelector('[data-launch="js-demo-{{ $uniq }}"]');
launchButton.addEventListener('click', function () {
var standalone = window.open();
standalone.document.body.innerHTML = demoDiv.innerHTML;
// For activating the script :-(
var newScript = standalone.document.createElement('script');
var oldScript = standalone.document.querySelector('script');
if (oldScript) {
newScript.textContent = oldScript.textContent;
oldScript.parentNode.removeChild(oldScript);
standalone.document.body.appendChild(newScript);
}
{{ if .Get "backgroundColor" }}
standalone.document.body.style.backgroundColor = {{ .Get "backgroundColor" | safeCSS }};
{{ end }}
standalone.document.title = 'demo ' + {{ $uniq }};
});
})();
</script>
</div>

View File

@ -1,5 +0,0 @@
{{ $html := .Inner | htmlEscape }}
{{ $html := replace $html "((" "<span class='highlight'>" }}
{{ $html := replace $html "))" "</span>" }}
{{ $numbered := .Get "numbered" }}
<div class="code-annotated {{ if and ($numbered) (ne $numbered "false") }}numbered{{ end }}"><code>{{ $html | safeHTML }}</code></div>

View File

@ -1,5 +0,0 @@
{{ if .IsNamedParams }}
<iframe src="https://jsbin.com/{{ .Get "id" }}/embed?{{ .Get "show" }}" title="JS Bin demo" height="300" width="100%"></iframe>
{{ else }}
<iframe src="https://jsbin.com/{{ .Get "id" }}/embed?output" title="JS Bin demo" height="300" width="100%"></iframe>
{{ end }}

View File

@ -1 +0,0 @@
{{ $title := .Get 0 }}{{ range .Site.Pages }}{{ if eq .Title $title }}<a class="pattern-link" href="{{ .Permalink }}"><svg class="bookmark" aria-hidden="true" viewBox="0 0 40 50" focusable="false"> <use xlink:href="#bookmark"></use> </svg>{{ .Title }}</a>{{ end }}{{ end -}}

View File

@ -3,8 +3,8 @@ license = "MIT"
licenselink = "https://github.com/zwbetz-gh/cupper-hugo-theme/blob/master/LICENSE"
description = "An accessibility-friendly Hugo theme, ported from the original Cupper project."
homepage = "https://github.com/zwbetz-gh/cupper-hugo-theme"
tags = ["accessible", "blog", "documentation"]
features = ["accessible", "blog", "documentation"]
tags = ["accessible", "blog", "documentation", "dark"]
features = ["accessible", "blog", "documentation", "dark"]
min_version = "0.48"
[author]