Added Author reader
This commit is contained in:
@@ -1,8 +1,12 @@
|
|||||||
import { config } from '@keystatic/core';
|
import { config } from '@keystatic/core';
|
||||||
|
|
||||||
|
import AuthorsCollection from '@/keystatic/collections/taxonomy/authors';
|
||||||
|
|
||||||
export default config({
|
export default config({
|
||||||
storage: {
|
storage: {
|
||||||
kind: 'local',
|
kind: 'local',
|
||||||
},
|
},
|
||||||
collections: {},
|
collections: {
|
||||||
|
authors: AuthorsCollection,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
0
src/keystatic/collections/taxonomy/index.ts
Normal file
0
src/keystatic/collections/taxonomy/index.ts
Normal file
6
src/lib/readers/base.ts
Normal file
6
src/lib/readers/base.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import { createReader } from '@keystatic/core/reader';
|
||||||
|
import { cache } from 'react';
|
||||||
|
import keystaticConfig from '~/keystatic.config';
|
||||||
|
|
||||||
|
export const reader = createReader(process.cwd(), keystaticConfig);
|
||||||
|
export { cache };
|
||||||
8
src/lib/readers/taxonomy/authors.ts
Normal file
8
src/lib/readers/taxonomy/authors.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { cache, reader } from '@/lib/readers/base';
|
||||||
|
|
||||||
|
export const getAuthors = cache(async () => reader.collections.authors.all());
|
||||||
|
|
||||||
|
export const getAuthorBySlug = cache(async (slug: string) => {
|
||||||
|
const author = await reader.collections.authors.read(slug);
|
||||||
|
return author ? { ...author, slug } : null;
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user