feat: add configurable prefixFolders option for folder page titles

Add prefixFolders option (default: false) to FolderPageOptions. When
false, generated folder pages use only the folder name as title instead
of 'Folder: full/path'. Also use last path segment only for the title
instead of the full folder path.
This commit is contained in:
saberzero1 2026-03-18 17:43:32 +01:00
parent 964ee8c7d7
commit 0deda78145
No known key found for this signature in database
6 changed files with 13 additions and 5 deletions

2
dist/index.d.ts vendored
View file

@ -1,4 +1,4 @@
export { F as FolderPage, a as FolderPageOptions } from './types-DjXd6K7r.js';
export { F as FolderPage, a as FolderPageOptions } from './types-B9xZH7g2.js';
export { FolderContent } from './components/index.js';
export { PageGenerator, PageMatcher, QuartzComponent, QuartzComponentConstructor, QuartzComponentProps, QuartzPageTypePlugin, QuartzPageTypePluginInstance, VirtualPage } from '@quartz-community/types';
import './PageList-DncPcZ4-.js';

3
dist/index.js vendored
View file

@ -314,7 +314,8 @@ var FolderPage = (opts) => {
for (const folder of folders) {
if (foldersWithIndex.has(folder)) continue;
const slug = joinSegments(folder, "index");
const title = `${i18n(locale).pages.folderContent.folder}: ${folder}`;
const folderName = folder.split("/").pop() ?? folder;
const title = opts?.prefixFolders ? `${i18n(locale).pages.folderContent.folder}: ${folderName}` : folderName;
virtualPages.push({
slug,
title,

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -5,6 +5,8 @@ interface FolderPageOptions {
showFolderCount?: boolean;
showSubfolders?: boolean;
sort?: SortFn;
/** Show "Folder: " prefix before folder name in generated titles. Default: false */
prefixFolders?: boolean;
}
declare const FolderPage: QuartzPageTypePlugin<FolderPageOptions>;

2
dist/types.d.ts vendored
View file

@ -1,3 +1,3 @@
export { BuildCtx, PageGenerator, PageMatcher, ProcessedContent, QuartzPageTypePlugin, QuartzPageTypePluginInstance, QuartzPluginData, StaticResources, VirtualPage } from '@quartz-community/types';
export { a as FolderPageOptions } from './types-DjXd6K7r.js';
export { a as FolderPageOptions } from './types-B9xZH7g2.js';
export { S as SortFn } from './PageList-DncPcZ4-.js';

View file

@ -15,6 +15,8 @@ export interface FolderPageOptions {
showFolderCount?: boolean;
showSubfolders?: boolean;
sort?: SortFn;
/** Show "Folder: " prefix before folder name in generated titles. Default: false */
prefixFolders?: boolean;
}
const folderMatcher: PageMatcher = ({ slug }) => {
@ -66,7 +68,10 @@ export const FolderPage: QuartzPageTypePlugin<FolderPageOptions> = (opts) => {
if (foldersWithIndex.has(folder)) continue;
const slug = joinSegments(folder, "index") as unknown as FullSlug;
const title = `${i18n(locale).pages.folderContent.folder}: ${folder}`;
const folderName = folder.split("/").pop() ?? folder;
const title = opts?.prefixFolders
? `${i18n(locale).pages.folderContent.folder}: ${folderName}`
: folderName;
virtualPages.push({
slug,