Added taxonomy/tags + reader
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { config } from '@keystatic/core';
|
||||
|
||||
import AuthorsCollection from '@/keystatic/collections/taxonomy/authors';
|
||||
import TagsCollection from '@/keystatic/collections/taxonomy/tags';
|
||||
|
||||
export default config({
|
||||
storage: {
|
||||
@@ -8,5 +9,6 @@ export default config({
|
||||
},
|
||||
collections: {
|
||||
authors: AuthorsCollection,
|
||||
tags: TagsCollection,
|
||||
},
|
||||
});
|
||||
|
||||
19
src/keystatic/collections/taxonomy/tags.ts
Normal file
19
src/keystatic/collections/taxonomy/tags.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { collection, fields } from '@keystatic/core';
|
||||
|
||||
export default collection({
|
||||
label: 'Tags',
|
||||
slugField: 'name',
|
||||
path: 'content/taxonomy/tags/*',
|
||||
format: { data: 'json' },
|
||||
schema: {
|
||||
name: fields.slug({
|
||||
name: {
|
||||
label: 'Name',
|
||||
},
|
||||
}),
|
||||
description: fields.text({
|
||||
label: 'Descriptions',
|
||||
multiline: true,
|
||||
}),
|
||||
},
|
||||
});
|
||||
8
src/lib/readers/taxonomy/tags.ts
Normal file
8
src/lib/readers/taxonomy/tags.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { cache, reader } from '@/lib/readers/base';
|
||||
|
||||
export const getTags = cache(async () => reader.collections.tags.all());
|
||||
|
||||
export const getTagBySlug = cache(async (slug: string) => {
|
||||
const tag = await reader.collections.tags.read(slug);
|
||||
return tag ? { ...tag, slug } : null;
|
||||
});
|
||||
Reference in New Issue
Block a user