Skip to content

Commit d79b8e9

Browse files
CopilotTechQuery
andcommitted
Merge file handling logic branches as requested
Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com>
1 parent 9668a17 commit d79b8e9

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

pages/api/core.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,18 @@ export async function* pageListOf(path: string, prefix = 'pages'): AsyncGenerato
8585
name = name.replace(MDX_pattern, '');
8686
path = `${path}/${name}`.replace(new RegExp(`^${prefix}`), '');
8787

88-
if (node.isFile() && isMDX) {
89-
const article: ArticleMeta = { name, path, subs: [] };
90-
try {
91-
const meta = await frontMatterOf(`${node.path}/${node.name}`);
92-
93-
if (meta) article.meta = meta;
94-
} catch (error) {
95-
console.error(`Error reading front matter for ${node.path}/${node.name}:`, error);
88+
if (node.isFile()) {
89+
const article: ArticleMeta = { name: isMDX ? name : node.name, path, subs: [] };
90+
91+
if (isMDX) {
92+
try {
93+
const meta = await frontMatterOf(`${node.path}/${node.name}`);
94+
if (meta) article.meta = meta;
95+
} catch (error) {
96+
console.error(`Error reading front matter for ${node.path}/${node.name}:`, error);
97+
}
9698
}
97-
yield article;
98-
} else if (node.isFile() && !isMDX) {
99-
// Handle non-Markdown files generically
100-
const article: ArticleMeta = { name: node.name, path, subs: [] };
99+
101100
yield article;
102101
} else if (node.isDirectory()) {
103102
const subs = await Array.fromAsync(pageListOf(path, prefix));

0 commit comments

Comments
 (0)