Skip to content

Commit 5eb5b74

Browse files
authored
centralize articles, video, and external data into global 11ty data (#1265)
* centralize articles, video, and external data into global 11ty data * Delete tutorials index.html and tutorials.11tydata.js * Update .prettierignore file. * address PR suggestions * update screenshot golden * Remove gray-matter from devDependencies.
1 parent e148d6c commit 5eb5b74

File tree

9 files changed

+158
-275
lines changed

9 files changed

+158
-275
lines changed

package-lock.json

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
}
6262
},
6363
"devDependencies": {
64-
"gray-matter": "^4.0.3",
6564
"playground-elements": "^0.18.0",
6665
"prettier": "^2.1.2",
6766
"typescript": "~4.7.4",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[
2+
{
3+
"relativeUrl": "https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals",
4+
"title": "ElementInternals",
5+
"heading": "",
6+
"text": "The ElementInternals interface of the Document Object Model gives web developers a way to allow custom elements to fully participate in HTML forms. It provides utilities for working with these elements in the same way you would work with any standard HTML form element, and also exposes the Accessibility Object Model to the element.",
7+
"docType": {
8+
"type": "MDN",
9+
"tag": "other"
10+
},
11+
"isExternal": true
12+
}
13+
]

packages/lit-dev-content/site/tutorials/tutorials.11tydata.js packages/lit-dev-content/site/_data/tutorials.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const path = require('path');
1818
* @typedef {{
1919
* featured: FeaturedOptions,
2020
* }} LoadDataOptions
21-
*/
21+
*/
2222

2323
/** @type{LoadDataOptions} */
2424
const defaultOptions = {featured: {position: undefined}};
@@ -33,7 +33,7 @@ const defaultOptions = {featured: {position: undefined}};
3333
* /tutorials/index.html
3434
*/
3535
const loadTutorialData = async (dirname, options = defaultOptions) => {
36-
options = {...defaultOptions, ...options}
36+
options = {...defaultOptions, ...options};
3737
const tutorialDir = path.resolve(
3838
__dirname,
3939
'../../samples/tutorials',
@@ -63,27 +63,25 @@ const loadTutorialData = async (dirname, options = defaultOptions) => {
6363
* To be consumed by the tutorials catalog (/tutorials/index.html).
6464
*/
6565
module.exports = async () => {
66-
const tutorials = await Promise.all([
66+
/*
67+
* tutorial data in order of rendering on the page plus stringified JSON for
68+
* search indexing.
69+
*/
70+
return await Promise.all([
6771
// Learn
6872
loadTutorialData('intro-to-lit', {featured: {position: 0}}),
6973
loadTutorialData('working-with-lists', {featured: {position: 1}}),
7074
loadTutorialData('reactivity'),
7175
loadTutorialData('custom-attribute-converter'),
7276
loadTutorialData('async-directive'),
7377

74-
7578
// Build
7679
loadTutorialData('svg-templates'),
7780
loadTutorialData('tooltip'),
7881
loadTutorialData('carousel', {featured: {position: 2}}),
7982
loadTutorialData('word-viewer'),
8083

8184
// Draft
82-
loadTutorialData('wc-to-lit'),
85+
// loadTutorialData('wc-to-lit'),
8386
]);
84-
/*
85-
* tutorial data in order of rendering on the page plus stringified JSON for
86-
* search indexing.
87-
*/
88-
return {eleventyComputed: {tutorials}};
8987
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/**
2+
* @license
3+
* Copyright 2023 Google LLC
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
const fs = require('fs').promises;
8+
const path = require('path');
9+
const matter = require('gray-matter');
10+
const {existsSync} = require('fs');
11+
12+
const rootSiteDir = path.resolve(__dirname, '..');
13+
14+
// Note: YouTube thumbnail images can be obtained with
15+
// https://i.ytimg.com/vi/<video id>/maxresdefault.jpg It should then be checked
16+
// into the GitHub repository at the native size 1280px by 720px, under the name
17+
// `images/videos/<video id>_2x.jpg`. Then also check-in a halved resolution
18+
// 640px by 360px image under the name `images/videos/<video id>.jpg`.
19+
//
20+
// Use https://squoosh.app/ to create the halved resolution image.
21+
const loadVideoData = () =>
22+
[
23+
{
24+
title: 'Declarative Reactive Web Components with Justin Fagnani',
25+
summary: `Justin covers what Web Components are and how LitElement and lit-html add value on top of the native APIs. This talk covers the fundamentals of how and why Lit is architected the way it is.`,
26+
youtubeId: '9FB0GSOAESo',
27+
date: 'Jun 22 2019',
28+
},
29+
{
30+
title: 'Chat with Lit #1 – Westbrook Johnson (Adobe)',
31+
summary: `Listen in on this live-recorded Twitter Space episode, hosted by Rody Davis (@rodydavis) and Elliott Marquez (@techytacos), with guest Westbrook Johnson (@WestbrookJ) from Adobe.`,
32+
youtubeId: 'it-NXhxkOJo',
33+
date: 'Jul 23 2021',
34+
},
35+
{
36+
title: 'Lit 2.0 Release Livestream',
37+
summary: `Lit 2.0 has officially landed! Here we talk about Lit 2.0, what we've been doing, what it means to Google, and what's new. Stay tuned for a panel discussion with Lit users in the industry!`,
38+
youtubeId: 'nfb779XIhsU',
39+
date: 'Sep 21 2021',
40+
},
41+
{
42+
title: 'How to build your first Lit component',
43+
summary: `Learn how to build your first Lit component and use it with React, Vue, and in a markdown editor.`,
44+
youtubeId: 'QBa1_QQnRcs',
45+
date: 'Apr 25 2022',
46+
},
47+
{
48+
title: 'What are elements?',
49+
summary: `Software Engineer Elliott Marquez shares what elements are, how to make, and interact with them. Learn about the basic building block of the web in this video!`,
50+
youtubeId: 'x_mixcGEia4',
51+
date: 'Apr 27 2022',
52+
},
53+
{
54+
title: 'How to build a carousel in Lit',
55+
summary: `In this video, we build a simple-carousel using Lit, letting us explore passing children into your web component, and web component composition.`,
56+
youtubeId: '2RftvylEtrE',
57+
date: 'May 3 2022',
58+
},
59+
{
60+
title: 'Event communication between web components',
61+
summary: `Follow along as Lit Software Engineer Elliott Marquez shares the pros, cons, and use cases of communicating with events.`,
62+
youtubeId: 'T9mxtnoy9Qw',
63+
date: 'May 5 2022',
64+
},
65+
{
66+
title: 'How to style your Lit elements',
67+
summary: `We cover how the Shadow DOM works, illustrate the benefits of encapsulated CSS, and show you how to use CSS inheritance, custom properties and shadow parts to expose a flexible public styling API.`,
68+
youtubeId: 'Xt7blcyuw5s',
69+
date: 'Oct 3 2022',
70+
},
71+
{
72+
title: 'Introduction to Lit',
73+
summary: `Learn all about the Lit library in this beginner-friendly Lit University episode! We will cover all of the essentials, including custom elements, declarative templates, scoped styles, and reactive properties.`,
74+
youtubeId: 'uzFakwHaSmw',
75+
date: 'Nov 2 2022',
76+
},
77+
{
78+
title: 'Lit 3.0 Launch Event',
79+
summary: `Join the Lit team to hear all about the Lit 3.0 release and what's new in the Lit ecosystem!`,
80+
youtubeId: 'ri9FEl_hRTc',
81+
date: 'Oct 10 2023',
82+
},
83+
].map((videoData) => ({
84+
kind: 'video',
85+
url: `https://www.youtube.com/watch?v=${videoData.youtubeId}`,
86+
...videoData,
87+
date: new Date(videoData.date),
88+
}));
89+
90+
/**
91+
* 11ty data JS loader.
92+
*
93+
* @returns {Promise<{eleventyComputed: {tutorials: Object[]}}>} 11ty data
94+
* To be consumed by the tutorials catalog (/tutorials/index.html).
95+
*/
96+
module.exports = async () => {
97+
return loadVideoData();
98+
};
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
eleventyComputed: {
3-
layout: "article",
4-
permalink: data => `/articles/${data.page.fileSlug}/`,
5-
}
6-
}
3+
layout: 'article',
4+
permalink: (data) => `/articles/${data.page.fileSlug}/`,
5+
},
6+
tags: ['articles'],
7+
};

0 commit comments

Comments
 (0)