@oddbird/eleventy-plugin-slide-deck v0.2.0
Eleventy Slide-Deck Plugin
A plugin to use the @oddbird/slide-deck
web component in eleventy projects --
and generate decks from data.
Config
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:
markdownItis an option object passed along to themarkdown-itpackagedomainis 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)- By default a slide with
pen: newwill provide a link to a blank new CodePen. UsenewPenTemplatesto 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>Usage
Build an entire slide-deck from structured data:
---yaml
slides:
- title: My Presentation
venue: Cool Web Club
date: 2024-11-20
caption: '@mia@front-end.social'
- 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.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 contentslide.background,slide.color, &slide.modeCSS values
<img-slide>slide.srcandslide.altto embed an imageslide.citefor (inline markdown) photo creditsslide.background,slide.fit,slide.position, &slide.paddingCSS values
<split-slide>-- combo ofimage-slideanddefault-slideprops<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.background,slide.fit,slide.position, &slide.paddingCSS values
<quote-slide>slide.quotethe (block markdown) text of the blockquoteslide.citea (inline markdown) citation after the quoteslide.avataran image next to the quote
<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 different
<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.
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">
@mia@front-end.social
</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
fit: contain
background: black
caption: >
I often try, actuallyTheme
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.