Helper macros for consistent embedding of
images, svg, video (iframes), and audio media –
as well as creating particular patterns
like media/icon-blocks, logo arrays, figures, galleries, etc.
Patterns
Media blocks create a side-by-side layout,
with constrained-width media on one side,
and text-content flowing to the other side.
Params:
-
media
{string}
The media to embed (this macro does not generate the media itself)
-
name
{string}
= ''
This name will be applied to the data-media
attribute
-
attrs
{object}
= {}
-
reverse
{boolean}
= false
-
content
{string}
= none
Provide either the content parameter or a caller()
block
Generate a figure from data, or pass in a caller()
block.
Params:
Embed a video file. For external videos, use youtube
for Youtube-hosted
videos and iframe
for everything else.
Params:
-
src
{url}
-
width
{number}
= none
-
height
{number}
= none
Place an image inside a screen, like an iphone.
Params:
-
device
{string}
Name of an icon in _includes/devices/
-
fill
{color}
= none
Color to use in any extra space around the image
-
content
{html}
= none
The image to embed (can also be passed into a caller()
block)
Generate a block of project logos.
Params:
Todo:
This is likely to move and expand to include page data.
Generate a series of media-blocks with icons
Params:
-
data
{array}
Each dictionary in the array should include an icon
and text
,
with optional title
and url
.
-
title
{string}
= none
The overall title for the icon-blocks section.
-
grid
{string}
= full
Embed a demo from CodePen
Params:
-
id
{string}
The “slug hash” of the desired pen
-
title
{string}
Used in the default fallback link
-
user
{string}
The CodePen username, eg ‘miriamsuzanne’
-
tab
{string}
= result
The tabs to have open by default, eg ‘html’ or ‘html,css,result’
-
height
{number | '100%'}
= 500
The pixel-height of the embed, or ‘100%’ to fit a sized container
-
theme
{string | 'light' | 'dark'}
= none
The embed-frame theme (not the code theme)
-
preview
{boolean}
= none
Set true
to keep the pen from auto-running
-
attrs
{array}
= {}
Links:
Embed a browser-support chart from CanIUse.
Params:
-
feature
{string}
The “slug” of the desired feature
-
periods
{string}
Optionally change what browser versions are shown.
-
script
{boolean}
= true
When using this multiple times in a single page,
there’s no reason to import the script every time.
Links:
Embed
Embed a video from Youtube
Params:
Embed an image
Params:
-
src
{url}
-
alt
{string}
= ''
-
sizes
{string | none}
= none
Only required for small images, since the default is 100vw.
See taxonomy data for named sizes
like “card”, “media”, and “gallery”.
-
attrs
{object}
= {}
Embed an svg file from the content/_includes/
folder
Params:
Embed an iframe (most often used for videos).
Width and height are provided both as defaults,
and to create intrinsic ratios when possible.
Params:
Embed an audio file
Params:
-
src
{url}
-
attrs
{object}
= {}
patterns
Generate a figure from one particular event.
Params:
Layout
Maintain aspect ratio for embedded media
Params:
See Also