All files / packages/content/src/core/domain content.ts

100% Statements 10/10
100% Branches 0/0
100% Functions 2/2
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 9610x   10x               10x   10x   10x   10x                                                                                                                                                   10x 12x   10x 19x  
export const ENTRY_RESOURCES = ["posts", "pages"] as const;
 
export const TERM_RESOURCES = ["categories", "tags"] as const;
 
export type EntryResource = (typeof ENTRY_RESOURCES)[number];
 
export type TermResource = (typeof TERM_RESOURCES)[number];
 
export type Resource = EntryResource | TermResource;
 
export const MAX_PAGE = 1000;
 
export const MAX_PER_PAGE = 50;
 
export const DEFAULT_PER_PAGE = 10;
 
export const MAX_SEARCH_LENGTH = 100;
 
export interface RichText {
    format: "html";
    value: string;
}
 
export interface Asset {
    id: string;
    url: string;
    alt: string;
    width?: number;
    height?: number;
}
 
export interface SEO {
    title?: string;
    description?: string;
    noindex?: boolean;
}
 
export interface Author {
    id: string;
    slug: string;
    name: string;
    bio?: string;
    avatar?: Asset;
}
 
export interface Term {
    id: string;
    resource: TermResource;
    slug: string;
    name: string;
    description?: string;
    seo?: SEO;
}
 
export interface Entry {
    id: string;
    slug: string;
    title: string;
    excerpt?: RichText;
    body: RichText;
    wordCount?: number;
    publishedAt?: string;
    updatedAt?: string;
    image?: Asset;
    terms: Term[];
    authors: Author[];
    seo?: SEO;
    fields?: Record<string, unknown>;
}
 
export interface Page<T> {
    items: T[];
    page: number;
    perPage: number;
    total: number;
    totalPages: number;
}
 
export interface Query {
    page?: number;
    perPage?: number;
    slug?: string;
    search?: string;
}
 
export type EntryQuery = Query & {
    term?: { resource: TermResource; id: string };
    author?: string;
};
 
export const isEntryResource = (resource: string | undefined): resource is EntryResource =>
    ENTRY_RESOURCES.includes(resource as EntryResource);
 
export const isTermResource = (resource: string | undefined): resource is TermResource =>
    TERM_RESOURCES.includes(resource as TermResource);