fix various tags & add warning logs when a tag is not defined

This commit is contained in:
James Fenn
2023-09-30 13:01:16 -04:00
parent d1ea967cb6
commit 9a675c046c
12 changed files with 74 additions and 61 deletions

View File

@@ -4,7 +4,7 @@
description: "Twitch streaming can be fun and fulfilling, but has various roadblocks in the way for newcomers. Here's how you can overcome them and grow your Twitch channel.",
published: '2023-03-25T21:52:59.284Z',
authors: ['crutchcorn'],
tags: ['opinion'],
tags: ['opinion', 'twitch'],
attached: [],
license: 'cc-by-4'
}

View File

@@ -4,7 +4,7 @@
description: 'Learn how to interactively debug your NodeJS applications using a GUI-based debugger built into Chrome.',
published: '2020-01-21T05:12:03.284Z',
authors: ['crutchcorn'],
tags: ['node', 'chrome'],
tags: ['nodejs', 'chrome'],
attached: [],
license: 'cc-by-nc-sa-4'
}

View File

@@ -4,7 +4,7 @@ title: "A Better Way To Code: Documentation Driven Development",
description: "Test Driven Development is often taught to improve a your workflow; I present Documentation Driven Development as an alternative approach.",
published: '2022-01-18T22:12:03.284Z',
authors: ['crutchcorn'],
tags: ['testing', 'opinion'],
tags: ['testing', 'opinion', 'documentation'],
attached: [],
license: 'cc-by-nc-sa-4',
}

View File

@@ -4,7 +4,7 @@
description: "You've heard a lot about Node, NPM, and Yarn - but aren't sure what they are. Let's introduce them in-depth and answer questions about them!",
published: '2021-04-05T22:12:03.284Z',
authors: ['crutchcorn'],
tags: ['webdev', 'javascript', 'node'],
tags: ['webdev', 'javascript', 'nodejs'],
attached: [],
license: 'cc-by-4'
}

View File

@@ -4,7 +4,7 @@
description: "Have you ever wanted to run native Java and Kotlin code from your mobile game written in Unity? Well, you can! Let's see how.",
published: '2020-01-04T05:12:03.284Z',
authors: ['crutchcorn'],
tags: ['unity', 'gamedev', 'android', 'csharp', 'java'],
tags: ['gamedev', 'android', 'csharp', 'java'],
attached: [],
license: 'cc-by-nc-sa-4'
}

View File

@@ -4,7 +4,7 @@
description: 'Save yourself money by hiding your API keys from prying eyes and nasty bots.',
published: '2020-04-20T22:07:09.945Z',
authors: ['MDutro'],
tags: ['react', 'node'],
tags: ['react', 'nodejs'],
attached: [],
license: 'cc-by-nc-nd-4'
}

View File

@@ -4,7 +4,7 @@
description: 'Join us as we teach you how to create a Slack bot from scratch using their Node SDK and MongoDB for persistence',
published: '2020-02-18T05:12:03.284Z',
authors: ['crutchcorn'],
tags: ['mongodb', 'node', 'slack'],
tags: ['mongodb', 'nodejs', 'slack'],
attached: [],
license: 'cc-by-nc-sa-4'
}

View File

@@ -4,7 +4,7 @@
description: "Learn the beginnings of data pack development in Minecraft - using positions, entity selectors, and conditional logic in commands!",
published: '2022-06-15T21:12:03.284Z',
authors: ['fennifith'],
tags: ["minecraft"],
tags: ["minecraft", "gamedev"],
attached: [],
license: 'cc-by-nc-sa-4',
collection: "minecraft-data-packs",

View File

@@ -5,7 +5,7 @@
published: '2022-06-14T21:12:03.284Z',
edited: '2023-09-12',
authors: ['fennifith'],
tags: ["minecraft"],
tags: ["minecraft", "gamedev"],
attached: [],
license: 'cc-by-nc-sa-4',
collection: "minecraft-data-packs",

View File

@@ -4,7 +4,7 @@
description: "Learn data pack development in Minecraft - using player scoreboards, variables, and operations!",
published: '2022-08-20T19:10:03.284Z',
authors: ['fennifith'],
tags: ["minecraft"],
tags: ["minecraft", "gamedev"],
attached: [],
license: 'cc-by-nc-sa-4',
collection: "minecraft-data-packs",

View File

@@ -104,6 +104,10 @@
"displayName": "Interviewing",
"emoji": "🤝"
},
"ios": {
"displayName": "iOS",
"emoji": "📱"
},
"java": {
"displayName": "Java",
"emoji": "☕"
@@ -219,9 +223,6 @@
"image": "/stickers/typescript.svg",
"shownWithBranding": false
},
"unity": {
"displayName": "Unity"
},
"vue": {
"displayName": "Vue",
"image": "/stickers/vue.svg",

View File

@@ -40,6 +40,54 @@ const licensesRaw = (await import("../../content/data/licenses.json")).default;
const tagsRaw = (await import("../../content/data/tags.json")).default;
const tags = new Map<string, TagInfo>();
// This needs to use a minimal version of our unified chain,
// as we can't import `createRehypePlugins` through an Astro
// file due to the hastscript JSX
const tagExplainerParser = unified()
.use(remarkParse, { fragment: true } as never)
.use(remarkTwoslash, { themes: ["css-variables"] })
.use(remarkToRehype, { allowDangerousHtml: true })
.use(rehypeUnicornElementMap)
.use(rehypeStringify, { allowDangerousHtml: true, voids: [] });
for (const [key, tag] of Object.entries(tagsRaw)) {
let explainer = undefined;
let explainerType = undefined;
if ("image" in tag && tag.image.endsWith(".svg")) {
const license = await fs.promises
.readFile("public" + tag.image.replace(".svg", "-LICENSE.md"), "utf-8")
.catch((_) => undefined);
const attribution = await fs.promises
.readFile(
"public" + tag.image.replace(".svg", "-ATTRIBUTION.md"),
"utf-8",
)
.catch((_) => undefined);
if (license) {
explainer = license;
explainerType = "license";
} else if (attribution) {
explainer = attribution;
explainerType = "attribution";
}
}
const explainerHtml = explainer
? (await tagExplainerParser.process(explainer)).toString()
: undefined;
tags.set(key, {
explainerHtml,
explainerType,
...tag,
});
}
const fullUnicorns: UnicornInfo[] = unicornsRaw.map((unicorn) => {
const absoluteFSPath = join(dataDirectory, unicorn.profileImg);
/**
@@ -228,11 +276,23 @@ function getPosts(): Array<PostInfo> {
*/
const wordCount = fileContents.split(/\s+/).length;
const frontmatterTags = [...frontmatter.tags].filter((tag) => {
if (tags.has(tag)) {
return true;
} else {
console.warn(
`${slug}: Tag '${tag}' is not specified in content/data/tags.json! Filtering...`,
);
return false;
}
});
return {
...frontmatter,
slug,
locales,
locale: locales[i],
tags: frontmatterTags,
authorsMeta: frontmatter.authors.map((authorId) =>
fullUnicorns.find((u) => u.id === authorId),
),
@@ -284,54 +344,6 @@ collections = collections.map((collection: Omit<CollectionInfo, "posts">) => ({
posts: posts.filter((post) => post.collection === collection.slug),
})) as CollectionInfo[];
const tags = new Map<string, TagInfo>();
// This needs to use a minimal version of our unified chain,
// as we can't import `createRehypePlugins` through an Astro
// file due to the hastscript JSX
const tagExplainerParser = unified()
.use(remarkParse, { fragment: true } as never)
.use(remarkTwoslash, { themes: ["css-variables"] })
.use(remarkToRehype, { allowDangerousHtml: true })
.use(rehypeUnicornElementMap)
.use(rehypeStringify, { allowDangerousHtml: true, voids: [] });
for (const [key, tag] of Object.entries(tagsRaw)) {
let explainer = undefined;
let explainerType = undefined;
if ("image" in tag && tag.image.endsWith(".svg")) {
const license = await fs.promises
.readFile("public" + tag.image.replace(".svg", "-LICENSE.md"), "utf-8")
.catch((_) => undefined);
const attribution = await fs.promises
.readFile(
"public" + tag.image.replace(".svg", "-ATTRIBUTION.md"),
"utf-8",
)
.catch((_) => undefined);
if (license) {
explainer = license;
explainerType = "license";
} else if (attribution) {
explainer = attribution;
explainerType = "attribution";
}
}
const explainerHtml = explainer
? (await tagExplainerParser.process(explainer)).toString()
: undefined;
tags.set(key, {
explainerHtml,
explainerType,
...tag,
});
}
export {
aboutRaw as about,
fullUnicorns as unicorns,