summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Swithinbank2023-05-04 22:14:41 +0200
committerGitHub2023-05-04 22:14:41 +0200
commit1016dc94ca463a55240bc41eeff9e3053712af45 (patch)
treebd5242d5445328b520f8fee21e8e9f5e44601681
parent7b9f27372c18a3737e83954ad303e94f74d62fa0 (diff)
downloadIT.starlight-1016dc94ca463a55240bc41eeff9e3053712af45.tar.gz
IT.starlight-1016dc94ca463a55240bc41eeff9e3053712af45.tar.bz2
IT.starlight-1016dc94ca463a55240bc41eeff9e3053712af45.zip
Refactor collection helper to only return the schema (#28)
-rw-r--r--docs/src/content/config.ts7
-rw-r--r--packages/starbook/schema.ts41
2 files changed, 23 insertions, 25 deletions
diff --git a/docs/src/content/config.ts b/docs/src/content/config.ts
index aecf6840..22718619 100644
--- a/docs/src/content/config.ts
+++ b/docs/src/content/config.ts
@@ -1,5 +1,8 @@
-import { defineDocsCollection } from 'starbook/schema';
+import { defineCollection } from 'astro:content';
+import { docsSchema } from 'starbook/schema';
export const collections = {
- docs: defineDocsCollection(),
+ docs: defineCollection({
+ schema: docsSchema(),
+ }),
};
diff --git a/packages/starbook/schema.ts b/packages/starbook/schema.ts
index b66f92d8..3178ba16 100644
--- a/packages/starbook/schema.ts
+++ b/packages/starbook/schema.ts
@@ -1,28 +1,23 @@
-import { defineCollection, z } from 'astro:content';
+import { z } from 'astro:content';
-export function defineDocsCollection() {
- return defineCollection({
- schema: z.object({
- /** The title of the current page. Required. */
- title: z.string(),
+export function docsSchema() {
+ return z.object({
+ /** The title of the current page. Required. */
+ title: z.string(),
- /**
- * A short description of the current page’s content. Optional, but recommended.
- * A good description is 150–160 characters long and outlines the key content
- * of the page in a clear and engaging way.
- */
- description: z.string().optional(),
+ /**
+ * A short description of the current page’s content. Optional, but recommended.
+ * A good description is 150–160 characters long and outlines the key content
+ * of the page in a clear and engaging way.
+ */
+ description: z.string().optional(),
- /**
- * Custom URL where a reader can edit this page.
- * Overrides the `editLink.baseUrl` global config if set.
- *
- * Can also be set to `false` to disable showing an edit link on this page.
- */
- editUrl: z
- .union([z.string().url(), z.boolean()])
- .optional()
- .default(true),
- }),
+ /**
+ * Custom URL where a reader can edit this page.
+ * Overrides the `editLink.baseUrl` global config if set.
+ *
+ * Can also be set to `false` to disable showing an edit link on this page.
+ */
+ editUrl: z.union([z.string().url(), z.boolean()]).optional().default(true),
});
}