generated from madrilene/eleventy-excellent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
356 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
--- | ||
title: Card | ||
--- | ||
|
||
<p> | ||
Previous to version 3, the card component was a Nunjucks include. There are a number of things that had to | ||
be set before being able to use it, like the level of the heading or whether tags shall be displayed. | ||
<a href="https://www.11ty.dev/docs/languages/webc/">WebC</a> | ||
makes this easier, as you can now use the custom element and opt in to the different slots. | ||
</p> | ||
|
||
<p><strong>Available slots:</strong></p> | ||
<ul> | ||
<li> | ||
image: the <code>image</code> shortcode has the <code>slot="image"</code> assigned to its | ||
<code>picture</code> or <code>figure</code> wrapper by default! | ||
</li> | ||
<li>headline: display the card's main title</li> | ||
<li> | ||
date and tag: Grouped within the classes <code>meta</code> and <code>cluster</code> for date and tagging | ||
information. | ||
</li> | ||
<li>content</li> | ||
<li>footer: for links or whatever footer information</li> | ||
</ul> | ||
|
||
<p>I added some <strong>variants</strong>, avaliable via attribute selectors:</p> | ||
|
||
<ul> | ||
<li><code>img-square</code>: Enforces a square aspect ratio for images.</li> | ||
<li><code>clickable</code>: Makes the whole card clickable.</li> | ||
<li><code>no-padding</code>: Removes padding and background modifications.</li> | ||
</ul> | ||
|
||
<strong>Usage</strong> | ||
|
||
<pre><code>{% raw %} | ||
<!--prettier-ignore--> | ||
<custom-card> | ||
{% image "path-to-img", "alt-text" %} | ||
<span slot="date"></span> | ||
<span slot="tag" class="button post-tag"></span> | ||
<h2 slot="headline"></h2> | ||
<p slot="content"></p> | ||
<footer slot="footer"></footer> | ||
</custom-card> | ||
{% endraw %}</code></pre> | ||
|
||
<strong>Example</strong> | ||
|
||
<div class="grid" data-layout="50-50"> | ||
<custom-card> | ||
{% image "./src/assets/images/gallery/asturias-3.jpg", "Close-up of a delicate white flower with a yellow center, surrounded by green leaves" %} | ||
<span slot="date">1516</span> | ||
<span slot="tag" class="button post-tag">Default</span> | ||
<h2 slot="headline">Utopia</h2> | ||
<p slot="content"> | ||
Among them, there is no sort of traffic, no knowledge of letters, no understanding of numbers, no name | ||
of magistrates, nor of politics, only of virtues; and they measure all things by barleycorns; their | ||
money, plate, and other ornaments they so diligently polish that no rust can stick to them. | ||
</p> | ||
<footer slot="footer"><a href="#">Link in the footer</a></footer> | ||
</custom-card> | ||
|
||
<custom-card clickable img-square> | ||
{% image "./src/assets/images/gallery/asturias-3.jpg", "Close-up of a delicate white flower with a yellow center, surrounded by green leaves" %} | ||
<span slot="date">18.02.1984</span> | ||
<div slot="tag" webc:nokeep> | ||
<span class="button post-tag">clickable</span><span class="button post-tag">square image</span> | ||
</div> | ||
<footer slot="footer"><a href="#">Link in the footer makes whole card a link</a></footer> | ||
<h2 slot="headline">The order does not matter</h2> | ||
</custom-card> | ||
|
||
<custom-card> | ||
<p slot="content"> | ||
They have no lawyers among them, for they consider them as a sort of people whose profession it is to | ||
disguise matters and to wrest the laws [...]. | ||
</p> | ||
<h2 slot="headline">Just title and content</h2> | ||
</custom-card> | ||
|
||
<custom-card no-padding> | ||
{% image "./src/assets/images/gallery/asturias-3.jpg", "Close-up of a delicate white flower with a yellow center, surrounded by green leaves" %} | ||
<p slot="content"> | ||
Red Hat's first logo appeared on an early invoice. It was a simple, bright red brimmed top hat placed | ||
above the words "Red Hat Software." | ||
</p> | ||
<h2 slot="headline">This card has no padding</h2> | ||
</custom-card> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
title: Config | ||
--- | ||
|
||
I like to divide things into small thematic areas, it helps me orient myself better. Configurations are structured into separate modules in `src/_config` and are then imported into the main configuration file. | ||
|
||
- **collections.js**: Manages Eleventy collections such as posts and tags: https://www.11ty.dev/docs/collections/ | ||
- **events.js**: For code that should run at certain times during the compiling process: https://www.11ty.dev/docs/events/ | ||
- **filters.js**: Used within templating syntax to transform data into a more presentable format: https://www.11ty.dev/docs/filters/ | ||
- **plugins.js**: Everything I or Eleventy considers to be a plugin: https://www.11ty.dev/docs/plugins/ | ||
- **shortcodes.js**: Defines shortcodes for reusable content: https://www.11ty.dev/docs/shortcodes/ | ||
|
||
Each configuration category (filters, plugins, shortcodes, etc.) is modularized. or example, `dates.js` within the `filters` folder contains date-related filters. | ||
|
||
```js | ||
import dayjs from 'dayjs'; | ||
|
||
export const toISOString = dateString => dayjs(dateString).toISOString(); | ||
export const formatDate = (date, format) => dayjs(date).format(format); | ||
``` | ||
|
||
These individual modules are then imported and consolidated in a central `filters.js` file, which exports all the filters as a single default object. | ||
|
||
```js | ||
import {toISOString, formatDate} from './filters/dates.js'; | ||
// more imports | ||
|
||
export default { | ||
toISOString, | ||
formatDate, | ||
// more exports | ||
}; | ||
|
||
``` | ||
|
||
**Integration in Eleventy Config** | ||
|
||
In the main Eleventy configuration file (`eleventy.config.js`), these modules are imported: | ||
|
||
```js | ||
import filters from './src/_config/filters.js'; | ||
import shortcodes from './src/_config/shortcodes.js'; | ||
``` | ||
|
||
They are then used to register filters and shortcodes with Eleventy, using this nice concise syntax: | ||
|
||
```js | ||
eleventyConfig.addFilter('toIsoString', filters.toISOString); | ||
eleventyConfig.addFilter('formatDate', filters.formatDate); | ||
// More filters... | ||
eleventyConfig.addShortcode('svg', shortcodes.svgShortcode); | ||
``` | ||
|
||
This method hopefully keeps the Eleventy config clean and focused, only concerning itself with the registration of functionalities, while the logic and definition remain abstracted in their respective modules. | ||
|
||
Some time ago I wrote a blog post about [how to organize the Eleventy configuration file](https://www.lenesaile.com/en/blog/organizing-the-eleventy-config-file/) where I go a little bit deeper into this topic. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
title: Details | ||
usage: "{% set itemList = collections.docs %}{% include 'partials/details.njk' %}" | ||
--- | ||
|
||
The `custom-details` WebC component has a corresponding Nunjucks include. | ||
It uses the `details` and `summary` elements to create a collapsible section and enhances them aesthetically and functionally. | ||
|
||
The JavaScript for the `custom-details` component adds functionality to buttons to expand and collapse the sections with one action. When JavaScript is disabled, the sections are still accessible and collapsible, but the extra buttons are hidden. | ||
|
||
On page load, it checks if a hash corresponding to a details ID exists in the URL. If such an ID is found, the corresponding details section is programmatically opened, allowing direct navigation to an open section from a shared URL. | ||
|
||
The sorting is set by default on "alphabetic", but you can also pass in "shuffle" or "reverse" as a parameter (directly in the `details.njk` partial). | ||
|
||
**Usage** | ||
|
||
``` | ||
{{ usage | safe }} | ||
``` | ||
|
||
**Example** | ||
|
||
You are in the middle of a custom details component! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"tags": "docs", | ||
"tags": "docs", | ||
"permalink": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
title: Easteregg | ||
--- | ||
|
||
The `custom-easteregg` component is by default in the base layout in `src/_layouts/base.njk`. Just delete the two lines if you don't want to use it. The component is | ||
designed to trigger a confetti effect when a user types a specific keyword sequence. It uses the dynamic import of the `canvas-confetti` library to render custom-shaped particles based on user input. | ||
|
||
**Defaults**: | ||
- **Keywords**: `"eleventy"`, `"excellent"` | ||
- **Shape**: `"⭐️"` | ||
- **Particle Count**: `30` | ||
|
||
**Customizable Attributes**: | ||
- `keyword`: custom keyword | ||
- `shape`: custom shape for the confetti particles using emojis or text | ||
- `particle-count`: number of particles to release during the effect | ||
|
||
|
||
``` | ||
<script type="module" src="/assets/scripts/components/custom-easteregg.js"></script> | ||
<custom-easteregg keyword="yay" shape="🌈" particle-count="50"></custom-easteregg> | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
title: JavaScript | ||
--- | ||
|
||
This starter has **no real JS dependency**. If JavaScript is not available, components that rely on it -- like the theme switcher -- will be hidden. If you opted in for the drawer menu, pills will be shown instead. | ||
|
||
There are two kinds of bundles for JavaScript in this starter, see `.src/_includes/head/js-inline.njk` and `.src/_includes/head/js-defer.njk`. | ||
By default, I include Eleventy's [is-land](https://github.com/11ty/is-land) framework and the theme toggle inline. | ||
|
||
You can include more scripts like so: | ||
|
||
{% raw %} | ||
|
||
```jinja2 | ||
{% js "inline" %} | ||
{% include "scripts/your-inline-script.js" %} | ||
{% endjs %} | ||
``` | ||
|
||
{% endraw %} | ||
|
||
Same goes for scripts that should be defered: | ||
|
||
{% raw %} | ||
|
||
```jinja2 | ||
{% js "defer" %} | ||
{% include "scripts/your-defered-script.js" %} | ||
{% endjs %} | ||
``` | ||
|
||
{% endraw %} | ||
|
||
Scripts stored in `src/assets/scripts/components/` are sent to the output folder, while scripts in `src/assets/scripts/bundle/` are sent to `.src/_includes/scripts/`, from where you can include them in the respective bundle. | ||
|
||
Some components are enhanced with JavaScript. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.