Added taxonomy/tags + reader
This commit is contained in:
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