GitHub

File tree

  • _data

  • _plugins

    • dsd

    • fed-embed

    • markdown

    • webmentions

  • assets

  • decks

    • devconf-brno-2023

    • pf-collab

    • redhat-frontend-guild-pfe

    • redhat-intro-web

    • semantic-component-testing

  • scripts

Original file line numberDiff line numberDiff line change

@@ -1 +1 @@

1-

v22.3.0

1+

v22.7.0

Original file line numberDiff line numberDiff line change

@@ -1,5 +1,2 @@

1-

const isWatching = () =>

1+

export default () =>

22

process.argv.includes('--watch') || process.argv.includes('--serve')

3-
4-

module.exports = isWatching;

5-
Original file line numberDiff line numberDiff line change

@@ -0,0 +1,5 @@

1+

import type { UserConfig } from '@11ty/eleventy';

2+
3+

export function DC23Plugin(eleventyConfig: UserConfig) {

4+

eleventyConfig.addPassthroughCopy('./decks/devconf-brno-2023/components/*.css');

5+

}

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,28 @@

1+

import type { Node, Element, Template } from '@parse5/tools'

2+
3+

type Attribute = Element['attrs'][number];

4+
5+

import { parse, serialize } from 'parse5';

6+

import { isElementNode, isTemplateNode, queryAll } from '@parse5/tools';

7+
8+

const isShadowRootMode = (attr: Attribute) =>

9+

attr.name === 'shadowrootmode';

10+
11+

const isWorkaround = (node: Node): node is Element =>

12+

isElementNode(node)

13+

&& node.tagName === 'webc-dsd-slot-workaround';

14+
15+

const isDSDTemplate = (node: Node): node is Template =>

16+

isTemplateNode(node)

17+

&& node.attrs?.some(isShadowRootMode);

18+
19+

export function transform(content: string) {

20+

const document = parse(content)

21+

for (const template of queryAll<Template>(document, isDSDTemplate)) {

22+

const { content } = template;

23+

for (const node of queryAll<Element>(content, isWorkaround)) {

24+

node.tagName = 'slot';

25+

}

26+

}

27+

return serialize(document);

28+

}

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,11 @@

1+

import type { UserConfig } from '@11ty/eleventy';

2+

import { transform } from './transform.ts';

3+
4+

export function WebCDSDWorkaroundPlugin(eleventyConfig: UserConfig) {

5+

eleventyConfig.addTransform('webc-dsd-slot-workaround', function(content: string) {

6+

if (this.page.outputPath?.endsWith?.('.html')) {

7+

return transform(content);

8+

}

9+

return content;

10+

});

11+

}

Original file line numberDiff line numberDiff line change

@@ -1,3 +1,5 @@

1+

import type { UserConfig } from '@11ty/eleventy';

2+
13

import getRegex from 'emoji-regex';

24

import names from 'emoji-short-name';

35

import html from 'dedent';

@@ -10,14 +12,10 @@ const RE = getRegex();

1012

* Wrap emoji in a span with an image role and aria-label

1113

* Thanks to Kitty Giraudel

1214

* @see https://kittygiraudel.com/2021/01/02/accessible-emojis-with-11ty/

13-

* @param {import('@11ty/eleventy').UserConfig} eleventyConfig

1415

*/

15-

export function EmojiWrapPlugin(eleventyConfig, { exclude }) {

16+

export function EmojiWrapPlugin(eleventyConfig: UserConfig, { exclude }) {

1617

eleventyConfig.addTransform('emojis',

17-

/**

18-

* @param {string} content

19-

*/

20-

function (content) {

18+

function (content: string) {

2119

if (!this.page.outputPath.endsWith?.('.html')

2220

|| (exclude && this.page.outputPath.match?.(exclude))) {

2321

return content;

Original file line numberDiff line numberDiff line change

@@ -1,7 +1,15 @@

1+

import type { UserConfig } from '@11ty/eleventy';

2+
13

import EleventyFetch from '@11ty/eleventy-fetch';

24
5+

interface FedEmbedOptions {

6+

post: string;

7+

}

8+
39

class FedEmbed {

4-

constructor(props) {

10+

post: URL;

11+
12+

constructor(props: FedEmbedOptions) {

513

const { post } = props;

614

this.post = new URL(post);

715

}

@@ -10,14 +18,14 @@ class FedEmbed {

1018

switch (true) {

1119

case (!!this.post): return this.renderPost();

1220

default:

13-

console.error(`No valid URLs found on ${JSON.stringify(props)}`);

21+

console.error(`No valid URLs found on ${JSON.stringify(this.post.href)}`);

1422

break;

1523

}

1624

}

1725
1826

async getPost() {

1927

const { origin, pathname } = this.post;

20-

let postURL;

28+

let postURL: URL;

2129

try {

2230

postURL = new URL(`${origin}/api/v1/statuses/${pathname.split('/').at(-1)}`);

2331

} catch (error) {

@@ -39,17 +47,16 @@ class FedEmbed {

3947

return post?.content ?? '';

4048

}

4149
42-

async fetch(sourceURL, opts) {

50+

async fetch(sourceURL: URL, opts?: { type: string; }) {

4351

const type = opts?.type ?? 'json';

4452

const href = typeof sourceURL === 'string' ? sourceURL : sourceURL.href;

4553

const res = await EleventyFetch(href, { duration: '4w', type });

4654

return res;

4755

}

4856

}

4957
50-

/** @param {import('@11ty/eleventy').UserConfig} eleventyConfig */

51-

export function FedEmbedPlugin(eleventyConfig) {

52-

eleventyConfig.addJavaScriptFunction('getFediPost', async post => {

58+

export function FedEmbedPlugin(eleventyConfig: UserConfig) {

59+

eleventyConfig.addJavaScriptFunction('getFediPost', async (post: string) => {

5360

if (post) {

5461

const embed = new FedEmbed({ post });

5562

const res = await embed.getPost();

Read the original on github.com ↗