Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/node_modules
/.pnp
.pnp.js
package-lock.json

# testing
/coverage
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "pages/article/Wiki"]
path = pages/article/Wiki
url = https://github.com/FreeCodeCamp-Chengdu/Wiki
[submodule "pages/article/PPT"]
path = pages/article/PPT
url = https://github.com/FreeCodeCamp-Chengdu/Activity_PPT
1 change: 1 addition & 0 deletions next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference path="./.next/types/routes.d.ts" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.
28 changes: 15 additions & 13 deletions pages/api/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,24 @@ export async function* pageListOf(path: string, prefix = 'pages'): AsyncGenerato
name = name.replace(MDX_pattern, '');
path = `${path}/${name}`.replace(new RegExp(`^${prefix}`), '');

if (node.isFile() && isMDX) {
const article: ArticleMeta = { name, path, subs: [] };
try {
const meta = await frontMatterOf(`${node.path}/${node.name}`);
if (node.isFile()) {
const article: ArticleMeta = { name: isMDX ? name : node.name, path, subs: [] };

if (meta) article.meta = meta;
} catch (error) {
console.error(`Error reading front matter for ${node.path}/${node.name}:`, error);
}
yield article;
}
if (!node.isDirectory()) continue;
if (isMDX)
try {
const meta = await frontMatterOf(`${node.path}/${node.name}`);

const subs = await Array.fromAsync(pageListOf(path, prefix));
if (meta) article.meta = meta;
} catch (error) {
console.error(`Error reading front matter for ${node.path}/${node.name}:`, error);
}

if (subs.length) yield { name, subs };
yield article;
} else if (node.isDirectory()) {
const subs = await Array.fromAsync(pageListOf(path, prefix));

if (subs.length) yield { name, subs };
}
}
}

Expand Down
1 change: 1 addition & 0 deletions pages/article/PPT
Submodule PPT added at 144859
2 changes: 1 addition & 1 deletion pages/article/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const getStaticProps = async () => {
const renderTree = (list: ArticleMeta[]) => (
<ol>
{list.map(({ name, path, meta, subs }) => (
<li key={name}>
<li key={path || name}>
{path ? (
<a
className="h4 d-flex justify-content-between align-items-center"
Expand Down
Loading