A plugin to use the
@oddbird/slide-deck
web component in eleventy projects --
and generate decks from data.
Any page with slides data
will be added to the (configurable) slideDeck collection,
and provided with a built-out slideDeck data property
ready for rendering.
We rely on the official WebC plugin, but don't install it for you. Configure both plugins, and register the provided components:
// 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, {
// optional slide deck configuration
});
// register the slide-deck WebC components
eleventyConfig.addPlugin(pluginWebc, {
components: [
'npm:@oddbird/eleventy-plugin-slide-deck/**/*.webc',
],
});
}There are several (optional) configuration settings for this slide deck plugin:
collectionNamechanges the name of the generatedslideDeckcollection, including every page that hasslidesdata.buildFunction(when provided) will be called on each slide during the build process, after relationships have resolved, but before layout is determined. Use this to set additional layout types or make other slide-data alterations.markdownItis an option object passed along to themarkdown-itpackagemarkdownFunctions.inline&markdownFunctions.blockallow replacing the markdown parser entirely, in case you want to add plugins or use a different library.domainis a string optionally prepended to the page url on event slides, to show the URL of the slide deckeventDateLocaleandeventDateFormatoptions for rendering the event date withtoLocaleDateString()imgDiroptionally prepends a path to all slide image properties (such assrcandavatar)known.slides(defaultknownSlides) andknown.series(defaultknownSeries) establish where to look for slide and series source data.
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: People who see your talk
---
<build-deck webc:nokeep :slides="this.slideDeck" id="if-you-want"></build-deck>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>Along with the core and (optional) theme style bundles:
<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>Create your slides in structured data,
using yaml or json or js objects.
We provide a number of built-in slide layouts
that accept a variety of properties:
-
all slide layouts support…
slide.idused for theidattributeslide.captionfor a caption under the slideslide.notefor speaker notesslide.source,slide.name, &slide.urlfor providing credit (often appended to thecaption)slide.citea reference to knownsource/name/urldata, or a markdown link (often appended to thecaption). This is useful when you want to provide source data without changing how the slide is rendered otherwise.slide.background,slide.color, &slide.modeCSS values
-
<event-slide>-- usually the first/last slides of a deckslide.pre,slide.title, &slide.subfor the talk title blockslide.venuethe event titleslide.datethe date of the talkslide.exitoptional (inline markdown) "back" link in the topslide.detailoptional (block markdown) section for more detail
-
<todo-slide>-- for drafting a new talkslide.todomarkdown block
-
<default-slide>-- titles, bullets, and arbitrary contentslide.pre,slide.title, andslide.subcreate the title blockslide.md, andslide.webcallow for arbitrary content
-
<img-slide>slide.srcandslide.altto embed an imageslide.creditfor (inline markdown) photo creditsslide.fit,slide.position, &slide.paddingCSS values
-
<split-slide>-- combo ofimage-slideanddefault-slideprops -
<source-slide>-- combo ofimage-slideandsource/name/urldata -
<url-slide>-- screenshot or open-graph image slide, generated from a url using the 11ty APIsslide.urlsource URLslide.altoptional alt text for the imageslide.sizecontrols the screenshot size/dimensionsslide.typecan be set toogto use the open-graph API insteadslide.titlewill be added to the caption (and used as alt-fallback)slide.fit,slide.position, &slide.paddingCSS values
-
<quote-slide>slide.quotethe (block markdown) text of the blockquoteslide.citea (inline markdown) citation after the quoteslide.imgorslide.avataran image next to the quoteslide.altoptional alt text for the avatar
-
<embed-slide>--slide.embedfor the code to embed (iframe, video, etc) -
<demo-slide>-- embeds and iframe, with a permalink in the captionslide.demoany URL or Eleventy page with matchingdemovalue
-
<pen-slide>-- embed editable demos from code-penslide.penURL of the CodePenslide.titlename of the pen, added to the captionslide.livelink a live-code version of the demo, if differentslide.preview(boolean) settruefor click-to-load behavior
-
<code-slide>slide.<language>(forhtml,css,scss, orjs)- or
slide.codeandslide.langfor any other languages
-
<support-slide>slide.caniusefeature id for CanIUseslide.supportfeature id for Baseline
All markdown properties also allow WebC content as well.
Reuse common slides across different decks
by creating adding a knownSlides object
to the Eleventy data cascade:
# _data/knownSlides.yml
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: topThese 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
note: yoda, with speaker notesRe-use an entire series of slides
with knownSeries data:
# _data/knownSeries.yml
intro:
- known: start-deck
title: New Presentation
venue: The Best Conference
- img: './my-image.jpg'
alt: Miriam smiling
title: Miriam Suzanne
sub: Web developerslides:
- series: intro
- title: More slides…Change the known.slides and known.series configuration options
to store known slide & series data under a different name.
Use the built-in <build-deck> component
to render a slide deck
using the provided slide layouts:
<build-deck webc:nokeep :slides="this.slideDeck"></build-deck>
<!-- be sure to include js and css bundles as needed -->For more flexibility
use the <slide-deck>,
<render-slide> and <slide-controls> components
to loop through your slide data --
and optionally add custom layouts…
<slide-deck
webc:import="npm:@oddbird/slide-deck"
:id="this.id || 'slides'"
:@slides="this.slides"
slide-view="slideshow"
key-control
follow-active
>
<template webc:nokeep webc:for="slide of this.slideDeck">
<!-- render custom layouts -->
<custom-slide-layout
webc:if="slide.layout === 'custom'"
:@slide="slide"
>
<!-- fall back to built-in layouts -->
<render-slide
webc:nokeep
webc:else
:@slide="slide"
></render-slide>
</template>
<slide-controls webc:nokeep></slide-controls>
</slide-deck>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.