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

@@ -1,11 +1,8 @@
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Cms {
export type ContentType = 'post' | 'page';
export interface ContentItem {
id: string;
title: string;
type: ContentType;
url: string;
description: string | undefined;
content: string;
@@ -15,8 +12,9 @@ export namespace Cms {
slug: string;
categories: Category[];
tags: Tag[];
parentId?: string;
children?: ContentItem[];
order: number;
children: ContentItem[];
parentId: string | undefined;
}
export interface Category {
@@ -32,44 +30,73 @@ export namespace Cms {
}
export interface GetContentItemsOptions {
type?: ContentType;
limit?: number;
offset?: number;
categories?: string[];
tags?: string[];
depth?: number;
parentIds?: string[];
}
export interface GetCategoriesOptions {
type?: ContentType;
slugs?: string[];
limit?: number;
offset?: number;
}
export interface GetTagsOptions {
type?: ContentType;
slugs?: string[];
limit?: number;
offset?: number;
}
}
/**
* Abstract class representing a CMS client.
*/
export abstract class CmsClient {
/**
* Retrieves content items based on the provided options.
* @param options - Options for filtering and pagination.
* @returns A promise that resolves to an array of content items.
*/
abstract getContentItems(
options?: Cms.GetContentItemsOptions,
): Promise<Cms.ContentItem[]>;
abstract getContentItemById(
id: string,
type?: string,
): Promise<Cms.ContentItem | undefined>;
/**
* Retrieves a content item by its ID and type.
* @param id - The ID of the content item.
* @returns A promise that resolves to the content item, or undefined if not found.
*/
abstract getContentItemById(id: string): Promise<Cms.ContentItem | undefined>;
/**
* Retrieves categories based on the provided options.
* @param options - Options for filtering and pagination.
* @returns A promise that resolves to an array of categories.
*/
abstract getCategories(
options?: Cms.GetCategoriesOptions,
): Promise<Cms.Category[]>;
/**
* Retrieves a category by its slug.
* @param slug - The slug of the category.
* @returns A promise that resolves to the category, or undefined if not found.
*/
abstract getCategoryBySlug(slug: string): Promise<Cms.Category | undefined>;
/**
* Retrieves tags based on the provided options.
* @param options - Options for filtering and pagination.
* @returns A promise that resolves to an array of tags.
*/
abstract getTags(options?: Cms.GetTagsOptions): Promise<Cms.Tag[]>;
/**
* Retrieves a tag by its slug.
* @param slug - The slug of the tag.
* @returns A promise that resolves to the tag, or undefined if not found.
*/
abstract getTagBySlug(slug: string): Promise<Cms.Tag | undefined>;
}