Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/content/banner/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { defineCollection } from "astro:content";
import { glob } from "astro/loaders";
import { z } from "astro/zod";
import { generateEntryId } from "../shared";

export const bannerCollection = defineCollection({
loader: glob({ pattern: '**/*.mdx', base: "./src/content/banner" }),
loader: glob({
pattern: '**/*.mdx',
base: "./src/content/banner",
generateId: generateEntryId,
}),
schema: () =>
z.object({
title: z.string(),
Expand Down
7 changes: 6 additions & 1 deletion src/content/contributor-docs/config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { defineCollection } from "astro:content";
import { glob } from "astro/loaders";
import { z } from "astro/zod";
import { generateEntryId } from "../shared";

/**
* Content collection for the Contribute section of the site.
*/
export const contributorDocsCollection = defineCollection({
loader: glob({ pattern: '**/*.mdx', base: "./src/content/contributor-docs" }),
loader: glob({
pattern: '**/*.mdx',
base: "./src/content/contributor-docs",
generateId: generateEntryId,
}),
schema: z.object({
title: z.string(),
description: z.string(),
Expand Down
7 changes: 6 additions & 1 deletion src/content/events/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { defineCollection, reference } from "astro:content";
import { glob } from "astro/loaders";
import { z } from "astro/zod";
import { generateEntryId } from "../shared";

export const eventsCollection = defineCollection({
loader: glob({ pattern: '**/*.mdx', base: "./src/content/events" }),
loader: glob({
pattern: '**/*.mdx',
base: "./src/content/events",
generateId: generateEntryId,
}),
schema: ({ image }) =>
z.object({
title: z.string(),
Expand Down
4 changes: 3 additions & 1 deletion src/content/examples/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineCollection, reference } from "astro:content";
import { glob } from "astro/loaders";
import { z } from "astro/zod";
import { generateEntryId } from "../shared";

/**
* Content collection for the Examples section of the site.
Expand All @@ -9,7 +10,8 @@ import { z } from "astro/zod";
export const examplesCollection = defineCollection({
loader: glob({
pattern: '**/*.mdx',
base: "./src/content/examples"
base: "./src/content/examples",
generateId: generateEntryId,
}),
schema: ({ image }) =>
z.object({
Expand Down
7 changes: 6 additions & 1 deletion src/content/homepage/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { defineCollection } from "astro:content";
import { glob } from "astro/loaders";
import { z } from "astro/zod";
import { generateEntryId } from "../shared";

export const homepageCollection = defineCollection({
loader: glob({ pattern: '**/*.yaml', base: "./src/content/homepage" }),
loader: glob({
pattern: '**/*.yaml',
base: "./src/content/homepage",
generateId: generateEntryId,
}),
schema: ({ image }) =>
z.object({
title: z.string(),
Expand Down
8 changes: 6 additions & 2 deletions src/content/libraries/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineCollection } from "astro:content";
import { z } from "astro/zod";
import { glob } from "astro/loaders";
import { author } from "../shared";
import { author, generateEntryId } from "../shared";

export const categories = [
"drawing",
Expand Down Expand Up @@ -29,7 +29,11 @@ export const categories = [
* Content collection for the Libraries section of the site.
*/
export const librariesCollection = defineCollection({
loader: glob({ pattern: '**/*.yaml', base: "./src/content/libraries" }),
loader: glob({
pattern: '**/*.yaml',
base: "./src/content/libraries",
generateId: generateEntryId,
}),
schema: ({ image }) =>
z.object({
// Name of the library
Expand Down
7 changes: 6 additions & 1 deletion src/content/pages/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { defineCollection } from "astro:content";
import { z } from "astro/zod";
import { glob } from "astro/loaders";
import { generateEntryId } from "../shared";

export const pagesCollection = defineCollection({
loader: glob({ pattern: '**/*.mdx', base: "./src/content/pages" }),
loader: glob({
pattern: '**/*.mdx',
base: "./src/content/pages",
generateId: generateEntryId,
}),
schema: () => z.object({
title: z.string(),
}),
Expand Down
7 changes: 6 additions & 1 deletion src/content/people/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineCollection } from "astro:content";
import { z } from "astro/zod";
import { glob } from "astro/loaders";
import { generateEntryId } from "../shared";

const peopleCategories = ["lead", "mentor", "alumni", "contributor"] as const;

Expand All @@ -9,7 +10,11 @@ const peopleCategories = ["lead", "mentor", "alumni", "contributor"] as const;
*
*/
export const peopleCollection = defineCollection({
loader: glob({ pattern: '**/*.yaml', base: "./src/content/people" }),
loader: glob({
pattern: '**/*.yaml',
base: "./src/content/people",
generateId: generateEntryId,
}),
schema: ({ image }) =>
z
.object({
Expand Down
8 changes: 6 additions & 2 deletions src/content/reference/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineCollection } from "astro:content";
import { z } from "astro/zod";
import { glob } from "astro/loaders";
import { relatedContent } from "../shared";
import { generateEntryId, relatedContent } from "../shared";

// Categories, ordered in a (rough) general-to-specific sequence for easier
// reading. Some bits that we haven't finished revising are moved lower down
Expand Down Expand Up @@ -93,6 +93,10 @@ export const referenceSchema = z.object({
});

export const referenceCollection = defineCollection({
loader: glob({ pattern: '**/*.mdx', base: "./src/content/reference" }),
loader: glob({
pattern: '**/*.mdx',
base: "./src/content/reference",
generateId: generateEntryId,
}),
schema: referenceSchema,
});
9 changes: 9 additions & 0 deletions src/content/shared.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { reference } from "astro:content";
import { z } from "astro/zod";

/**
* Generates an entry ID that preserves the original file path casing.
* Astro's default glob() loader lowercases IDs via github-slugger, which
* breaks locale matching for codes like "zh-Hans". Using the raw path
* (without extension) keeps IDs consistent with the folder structure.
*/
export const generateEntryId = ({ entry }: { entry: string }): string =>
entry.replace(/\.(mdx|yaml)$/, "");

/*
* A zod type for an author.
* has a name and an optional URL to link to
Expand Down
7 changes: 6 additions & 1 deletion src/content/text-detail/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { defineCollection } from "astro:content";
import { z } from "astro/zod";
import { glob } from "astro/loaders";
import { generateEntryId } from "../shared";

export const textDetailCollection = defineCollection({
loader: glob({ pattern: '**/*.mdx', base: "./src/content/text-detail" }),
loader: glob({
pattern: '**/*.mdx',
base: "./src/content/text-detail",
generateId: generateEntryId,
}),
schema: ({ image }) =>
z.object({
title: z.string(),
Expand Down
8 changes: 6 additions & 2 deletions src/content/tutorials/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineCollection } from "astro:content";
import { z } from "astro/zod";
import { glob } from "astro/loaders";
import { relatedContent } from "../shared";
import { generateEntryId, relatedContent } from "../shared";

export const categories = [
"2.0",
Expand All @@ -19,7 +19,11 @@ export const categories = [
* Content collection for the Sketches showcase section of the site.
*/
export const tutorialsCollection = defineCollection({
loader: glob({ pattern: '**/*.mdx', base: "./src/content/tutorials" }),
loader: glob({
pattern: '**/*.mdx',
base: "./src/content/tutorials",
generateId: generateEntryId,
}),
schema: ({ image }) =>
z
.object({
Expand Down