Compare commits

..

3 Commits

Author SHA1 Message Date
Helen Chong
98fc3201d8 Improve shortcode and filter comments 2025-03-27 00:20:12 +08:00
Helen Chong
8663ab10c5 Add "In Praise of Links" 2025-03-26 09:32:29 +08:00
Helen Chong
26a8a967e9 Set auto height for images 2025-03-26 00:42:21 +08:00
4 changed files with 16 additions and 11 deletions

View File

@ -1,7 +1,7 @@
import { DateTime } from "luxon";
export default function(eleventyConfig) {
// Filter contents by category
// Filter: Filter contents by category
eleventyConfig.addFilter("filterByCategory", function(contents, cat) {
cat = cat.toLowerCase();
let result = contents.filter(item => {
@ -11,7 +11,7 @@ export default function(eleventyConfig) {
return result;
});
// Format dates
// Filter: Format dates
eleventyConfig.addFilter("formatDate", (date) => {
const dateFormat = "d LLLL yyyy";
if (typeof date === "object") {
@ -20,12 +20,12 @@ export default function(eleventyConfig) {
return DateTime.fromISO(date, { setZone: true }).toFormat(dateFormat);
});
// Limit number of items displayed
// Filter: Limit number of items displayed
eleventyConfig.addFilter("itemLimit", function(array, maximum) {
return array.slice(0, maximum);
});
// Thousands separator
// Filter: Thousands separator
eleventyConfig.addFilter("thousands", function(num) {
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
});

View File

@ -2,10 +2,10 @@ import slugify from "slugify";
import { markdownLibrary } from "./markdown-it.js";
export default function(eleventyConfig) {
// <cite> tag
// Shortcode: <cite> tag
eleventyConfig.addShortcode('cite', (str) => `<cite>${str}</cite>`);
// Manual heading anchor
// Shortcode: Manual heading anchor
eleventyConfig.addPairedShortcode('headingAnchor', (title, hLevel, id=slugify(title)) => {
return `<div class="heading-wrapper h${hLevel}">
<h${hLevel} id="${id}">${title}</h${hLevel}>
@ -13,14 +13,14 @@ export default function(eleventyConfig) {
</div>`;
});
// Custom container
// Shortcode: Custom container
eleventyConfig.addPairedShortcode('container', (children, el, className) => {
const classMarkup = className ? ` class="${className}"` : "";
const content = markdownLibrary.render(children);
return `<${el}${classMarkup}>${content}</${el}>`;
});
// Image figure and figcaption
// Shortcode: Image figure and figcaption
eleventyConfig.addPairedShortcode('imgFigure', (
caption, img, alt=caption, className, enableLazyLoading=true
) => {
@ -32,7 +32,7 @@ export default function(eleventyConfig) {
</figure>`;
});
// Content disclosure
// Shortcode: Content disclosure
eleventyConfig.addPairedShortcode('disclosure', (content, summary) => {
const summaryMarkup = markdownLibrary.renderInline(summary);
const contentMarkup = markdownLibrary.render(content);
@ -42,7 +42,7 @@ export default function(eleventyConfig) {
</details>`;
});
// Paired shorcode: Content warning disclosure
// Shortcode: Content warning disclosure
eleventyConfig.addPairedShortcode('contentWarning', (content, warning) => {
const warningMarkup = markdownLibrary.renderInline(warning);
const contentMarkup = markdownLibrary.render(content);

View File

@ -86,6 +86,7 @@
img, picture, video, canvas {
max-width: 100%;
height: auto;
display: block;
}

View File

@ -1,7 +1,7 @@
---
title: Articles
date: 2024-07-03
updated: 2024-12-13T22:10:06+0800
updated: 2025-03-26T09:32:17+0800
toc: true
---
@ -43,6 +43,10 @@ toc: true
Nora Reed's website manifesto has been my go-to recommendated reading for why you should make your own website rather than relying on social media for your web presence.{.item-list__indent}
* [In Praise of Links](https://osteophage.neocities.org/writing/in-praise-of-links) by Coyote
Hyperlinks keep the web alive. This is also why link pages like this exist.{.item-list__indent}
* [The one app to read them all already exists, and its called RSS](https://journal.jatan.space/why-use-rss/) by Jatan Mehta
I have been subscribing to RSS feeds since the 2000s to follow website and blog updates, and I encourage more internet users to do the same.