diff --git a/.gitignore b/.gitignore index d7f3e09b2..39b33d86b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /node_modules /.pnp .pnp.js +package-lock.json # testing /coverage diff --git a/.gitmodules b/.gitmodules index da43b7ef9..1df6737fc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/next-env.d.ts b/next-env.d.ts index 52e831b43..254b73c16 100644 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -1,5 +1,6 @@ /// /// +/// // NOTE: This file should not be edited // see https://nextjs.org/docs/pages/api-reference/config/typescript for more information. diff --git a/pages/api/core.ts b/pages/api/core.ts index 5003a5af4..65bad72ce 100644 --- a/pages/api/core.ts +++ b/pages/api/core.ts @@ -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 }; + } } } diff --git a/pages/article/PPT b/pages/article/PPT new file mode 160000 index 000000000..144859de4 --- /dev/null +++ b/pages/article/PPT @@ -0,0 +1 @@ +Subproject commit 144859de471707164a51a94b61caaef6f6a7f76f diff --git a/pages/article/index.tsx b/pages/article/index.tsx index c845517e6..a54bdfc53 100644 --- a/pages/article/index.tsx +++ b/pages/article/index.tsx @@ -16,7 +16,7 @@ export const getStaticProps = async () => { const renderTree = (list: ArticleMeta[]) => (
    {list.map(({ name, path, meta, subs }) => ( -
  1. +
  2. {path ? (