Update content categorization and handle hierarchical documentation

Enhancements were implemented to support hierarchical documentation. Local CMS now respects parent ID and order attributes of content items, and content can be categories as 'blog' or 'documentation'. Changes were also made to the wordpress integration supporting these new categorizations. Introduced working with nested documentation pages.
This commit is contained in:
giancarlo
2024-04-03 21:06:54 +08:00
parent 3fd216ba6e
commit 53afd10f32
22 changed files with 350 additions and 156 deletions

View File

@@ -66,6 +66,13 @@ export const Post = defineDocumentType(() => ({
type: 'string',
resolve: (post) => `/blog/${getSlug(post._raw.sourceFileName)}`,
},
parentId: {
type: 'string',
resolve: (doc) => {
const segments = getPathSegments(doc);
return segments.length > 1 ? segments.slice(0, -1).join('/') : 'blog';
},
},
structuredData: {
type: 'object',
resolve: (doc) => ({
@@ -124,6 +131,33 @@ export const DocumentationPage = defineDocumentType(() => ({
type: 'number',
resolve: (post) => calculateReadingTime(post.body.raw),
},
parentId: {
type: 'string',
resolve: (doc) => {
const segments = getPathSegments(doc);
if (segments.length > 1) {
const { pathName } = getMetaFromFolderName(segments[0]);
if (pathName === 'index') {
return undefined;
}
return pathName;
}
return undefined;
},
},
order: {
type: 'number',
resolve: (doc) => {
const segments = getPathSegments(doc);
const { order } = getMetaFromFolderName(segments[segments.length - 1]);
return order;
},
},
structuredData: {
type: 'object',
resolve: (doc) => ({