mirror of
https://github.com/quartz-community/folder-page.git
synced 2026-07-22 02:50:24 +00:00
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:
parent
964ee8c7d7
commit
0deda78145
6 changed files with 13 additions and 5 deletions
2
dist/index.d.ts
vendored
2
dist/index.d.ts
vendored
|
|
@ -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
3
dist/index.js
vendored
|
|
@ -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
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
|
@ -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
2
dist/types.d.ts
vendored
|
|
@ -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';
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue