refactor: use QuartzPluginData for PageEntry instead of duplicated shape

Replace the hand-written PageEntry type with an intersection of
QuartzPluginData and Record<string, unknown>. This keeps PageEntry
structurally aligned with the upstream contract so future DataMap
additions (e.g. the FullSlug branding that prompted this change) do
not require boundary casts on listProps.allFiles.

Construction sites that build a PageEntry from a plain string slug
now cast with 'as FullSlug' at the natural brand-boundary, matching
how slugs are produced elsewhere in the codebase.

The interface-extends form previously tried in PageList.tsx (removed
in commit e6a5d27 because it broke DTS builds) is not used here; the
intersection type alias inlines cleanly into the generated .d.ts.
This commit is contained in:
saberzero1 2026-04-16 15:16:42 +02:00
parent 0bee9810de
commit d9fec1c6f7
No known key found for this signature in database
3 changed files with 8 additions and 11 deletions

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,9 @@
import type {
FullSlug,
QuartzComponent,
QuartzComponentConstructor,
QuartzComponentProps,
QuartzPluginData,
SortFn,
} from "@quartz-community/types";
import { PageList } from "./PageList";
@ -31,12 +33,7 @@ interface TrieNode {
findNode(path: string[]): TrieNode | undefined;
}
type PageEntry = {
slug?: string;
unlisted?: boolean;
dates?: { created: Date; modified: Date; published: Date };
frontmatter?: { title?: string; tags?: string[] };
};
type PageEntry = QuartzPluginData & Record<string, unknown>;
function concatenateResources(
...resources: (string | string[] | undefined)[]
@ -56,7 +53,7 @@ function pagesFromTrie(folder: TrieNode, showSubfolders: boolean): PageEntry[] {
if (node.isFolder && showSubfolders) {
return {
slug: node.slug,
slug: node.slug as FullSlug,
dates: mostRecentDatesFromChildren(node.children),
frontmatter: { title: node.displayName, tags: [] },
};
@ -106,7 +103,7 @@ export function pagesFromAllFiles(
if (indexFile) continue;
directChildren.push({
slug: `${folderPrefix}${subfolderName}/index`,
slug: `${folderPrefix}${subfolderName}/index` as FullSlug,
dates: mostRecentDatesFromEntries(files),
frontmatter: { title: subfolderName, tags: [] },
});
@ -178,7 +175,7 @@ export default ((opts?: Partial<FolderContentOptions>) => {
const listProps = {
...props,
sort: options.sort,
allFiles: allPagesInFolder as unknown as QuartzComponentProps["allFiles"],
allFiles: allPagesInFolder,
};
const hastRoot = tree as Root;