diff options
author | Chris Swithinbank | 2023-05-04 22:14:41 +0200 |
---|---|---|
committer | GitHub | 2023-05-04 22:14:41 +0200 |
commit | 1016dc94ca463a55240bc41eeff9e3053712af45 (patch) | |
tree | bd5242d5445328b520f8fee21e8e9f5e44601681 | |
parent | 7b9f27372c18a3737e83954ad303e94f74d62fa0 (diff) | |
download | IT.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.ts | 7 | ||||
-rw-r--r-- | packages/starbook/schema.ts | 41 |
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), }); } |