A plugin to use the @oddbird/slide-deck
web component in eleventy projects --
and generate decks from data.
We rely on the official WebC plugin, but don't install it for you.
// eleventy config
import pluginWebc from "@11ty/eleventy-plugin-webc";
import pluginSlideDeck from "@oddbird/eleventy-plugin-slide-deck";
export default async function(eleventyConfig) {
eleventyConfig.addPlugin(pluginSlideDeck);
// register the slide-deck WebC components
eleventyConfig.addPlugin(pluginWebc, {
components: [
'npm:@oddbird/eleventy-plugin-slide-deck/**/*.webc',
],
});
}
There are several configuration options for the plugin:
markdownIt
is an option object passed along to themarkdown-it
packagedomain
is a string optionally prepended to the page url on event slides, to show the URL of the slide deckeventDateLocale
andeventDateFormat
options for rendering the event date withtoLocaleDateString()
imgDir
optionally prepends a path to all slide image properties (such assrc
andavatar
)- By default a slide with
pen: new
will provide a link to a blank new CodePen. UsenewPenTemplates
to optionally register additional template shortcuts for generating new CodePens on the fly.
JavaScript for interactivity and loading the baseline support
content are
included in the default bundle. Make sure it's included in a template.
<script webc:keep @raw="getBundle('js')"></script>
Build an entire slide-deck from structured data:
---yaml
slides:
- title: My Presentation
venue: Cool Web Club
date: 2024-11-20
caption: '@[email protected]'
- img: './my-image.jpg'
alt: a very tall or short building or not a building at all
- quote: "This is one of the bests talks I've ever seen"
cite: You, Later
---
<build-deck webc:nokeep :slides="this.slides" id="if-you-want"></build-deck>
<style @raw="getBundle('css', 'slides-layer-order')" webc:keep></style>
<style @raw="getBundle('css', 'slides-core')" webc:keep></style>
<!--- Add optional slide theme styles --->
<style @raw="getBundle('css', 'slides-theme')" webc:keep></style>
Or build your own, using the provided slide types.
All of them accept a slide
object
with slide.id
, slide.caption
, and slide.note
properties.
Each slide type also accepts some type-specific properties:
-
<event-slide>
-- usually the first/last slides of a deckslide.pre
,slide.title
, &slide.sub
for the talk title blockslide.venue
the event titleslide.date
the date of the talkslide.exit
optional (inline markdown) "back" link in the topslide.detail
optional (block markdown) section for more detail
-
<todo-slide>
-- for drafting a new talkslide.todo
markdown block
-
<default-slide>
-- titles, bullets, and arbitrary contentslide.pre
,slide.title
, andslide.sub
create the title blockslide.md
, andslide.webc
allow for arbitrary contentslide.background
,slide.color
, &slide.mode
CSS values
-
<img-slide>
slide.src
andslide.alt
to embed an imageslide.cite
for (inline markdown) photo creditsslide.background
,slide.fit
,slide.position
, &slide.padding
CSS values
-
<split-slide>
-- combo ofimage-slide
anddefault-slide
props -
<url-slide>
-- screenshot or open-graph image slide, generated from a url using the 11ty APIsslide.url
source URLslide.alt
optional alt text for the imageslide.size
controls the screenshot size/dimensionsslide.type
can be set toog
to use the open-graph API insteadslide.title
will be added to the caption (and used as alt-fallback)slide.background
,slide.fit
,slide.position
, &slide.padding
CSS values
-
<quote-slide>
slide.quote
the (block markdown) text of the blockquoteslide.cite
a (inline markdown) citation after the quoteslide.avatar
an image next to the quote
-
<embed-slide>
--slide.embed
for the code to embed (iframe, video, etc) -
<demo-slide>
-- embeds and iframe, with a permalink in the captionslide.demo
any URL or Eleventy page with matchingdemo
value
-
<pen-slide>
-- embed editable demos from code-penslide.pen
URL of the CodePenslide.title
name of the pen, added to the captionslide.live
link a live-code version of the demo, if different
-
<code-slide>
slide.<language>
(forhtml
,css
,scss
, orjs
)- or
slide.code
andslide.lang
for any other languages
-
<support-slide>
slide.caniuse
feature id for CanIUseslide.support
feature id for Baseline
All markdown properties also allow WebC
content.
Reuse common slides across different decks
by creating adding a knownSlides
object
to the Eleventy data cascade:
start-deck:
exit: >
[home](/)
caption: |
<img src="oddbird-logo.svg" alt="OddBird" sizes="96w" width="180">
<a href="https://front-end.social/@mia">
@[email protected]
</a>
<span>
(<kbd>Cmd/Ctr-k</kbd> for settings)
</span>
yoda:
img: yoda.jpg
alt: Yoda using the force in a swamp
fit: cover
position: top
These can be referenced in a slide deck,
using the slide.known
property.
Additional properties added here
will be combined with (or override)
properties in the known slide:
slides:
- known: start-deck
title: New Presentation
venue: The Best Conference
- known: yoda
fit: contain
background: black
caption: >
I often try, actually
To get started using the provided
default theme, add the slides-theme
bundle to your project:
<style @raw="getBundle('css', 'slides-theme')" webc:keep></style>
The theme in this layer adds settings for colors, basic styling, and fonts.
In the slides-theme
layer we list
default font stacks for sans-serif
(--slide-os-sans-font
), serif (--slide-os-serif-font
),
and code (--slide-os-code-font
) fonts.
To add a main font for each font stack type, manually add self-hosted or web-based fonts to your project and then set the font-family name to the respective custom property for each font.
Example:
--slide-web-font-sans: "Recursive Sans Linear";
--slide-web-font-serif: freight-text-pro;
There's more to document, but this is a start.