From 7499ed6a31f44eb595c41782f817198c16ce8527 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Sat, 20 Jul 2024 01:21:21 -1100 Subject: [PATCH] Add support for onlyDirectories --- src/plugins/markdown-pages/discover.js | 5 +++-- src/plugins/markdown-pages/markdown-pages.js | 4 ++-- src/plugins/markdown-pages/types.ts | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/markdown-pages/discover.js b/src/plugins/markdown-pages/discover.js index 828003b2..df19fff3 100644 --- a/src/plugins/markdown-pages/discover.js +++ b/src/plugins/markdown-pages/discover.js @@ -11,17 +11,18 @@ import { reshape } from './hydrate.js'; * @typedef {object} Options * @property {string | undefined} [ src ] * @property {Group[] | undefined} [ groups ] + * @property {Group[] | undefined} [ onlyDirectories ] * * @param {Options} options * @return {Promise} */ -export async function discover({ groups, src }) { +export async function discover({ groups, src, onlyDirectories }) { groups ??= []; let groupsToLookFor = new Set(); if (src) { - groupsToLookFor.add({ name: 'root', src }); + groupsToLookFor.add({ name: 'root', src, onlyDirectories }); } groups.map((group) => groupsToLookFor.add(group)); diff --git a/src/plugins/markdown-pages/markdown-pages.js b/src/plugins/markdown-pages/markdown-pages.js index 46dfcbdc..f1123d54 100644 --- a/src/plugins/markdown-pages/markdown-pages.js +++ b/src/plugins/markdown-pages/markdown-pages.js @@ -12,7 +12,7 @@ const SECRET_INTERNAL_IMPORT = 'kolay/manifest:virtual'; /** @type {(options: import('./types.ts').MarkdownPagesOptions) => import('unplugin').UnpluginOptions} */ export const markdownPages = (options) => { - let { src, dest, name, groups } = options ?? {}; + let { src, dest, name, groups, onlyDirectories } = options ?? {}; const destination = dest ?? 'kolay-manifest'; @@ -43,7 +43,7 @@ export const markdownPages = (options) => { `use the 'groups' key.` ); - const reshaped = await discover({ src, groups }); + const reshaped = await discover({ src, groups, onlyDirectories }); if (groups) { groups.forEach((group) => { diff --git a/src/plugins/markdown-pages/types.ts b/src/plugins/markdown-pages/types.ts index 1f068b07..1448b958 100644 --- a/src/plugins/markdown-pages/types.ts +++ b/src/plugins/markdown-pages/types.ts @@ -7,6 +7,7 @@ export type GatheredDocs = Array<{ mdPath: string; config?: object }>; export interface MarkdownPagesOptions { src?: string | undefined; + onlyDirectories?: boolean; groups: { name: string; src: string;