Skip to content

Commit ad25c1f

Browse files
CopilotTechQuery
andauthored
[add] Git submodule of Activity PPT (#42)
Co-authored-by: South Drifter <shiy2008@gmail.com>
1 parent 13012cb commit ad25c1f

File tree

6 files changed

+22
-14
lines changed

6 files changed

+22
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/node_modules
55
/.pnp
66
.pnp.js
7+
package-lock.json
78

89
# testing
910
/coverage

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "pages/article/Wiki"]
22
path = pages/article/Wiki
33
url = https://github.com/FreeCodeCamp-Chengdu/Wiki
4+
[submodule "pages/article/PPT"]
5+
path = pages/article/PPT
6+
url = https://github.com/FreeCodeCamp-Chengdu/Activity_PPT

next-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3+
/// <reference path="./.next/types/routes.d.ts" />
34

45
// NOTE: This file should not be edited
56
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.

pages/api/core.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,24 @@ 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}`);
88+
if (node.isFile()) {
89+
const article: ArticleMeta = { name: isMDX ? name : node.name, path, subs: [] };
9290

93-
if (meta) article.meta = meta;
94-
} catch (error) {
95-
console.error(`Error reading front matter for ${node.path}/${node.name}:`, error);
96-
}
97-
yield article;
98-
}
99-
if (!node.isDirectory()) continue;
91+
if (isMDX)
92+
try {
93+
const meta = await frontMatterOf(`${node.path}/${node.name}`);
10094

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

103-
if (subs.length) yield { name, subs };
100+
yield article;
101+
} else if (node.isDirectory()) {
102+
const subs = await Array.fromAsync(pageListOf(path, prefix));
103+
104+
if (subs.length) yield { name, subs };
105+
}
104106
}
105107
}
106108

pages/article/PPT

Submodule PPT added at 144859d

pages/article/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const getStaticProps = async () => {
1616
const renderTree = (list: ArticleMeta[]) => (
1717
<ol>
1818
{list.map(({ name, path, meta, subs }) => (
19-
<li key={name}>
19+
<li key={path || name}>
2020
{path ? (
2121
<a
2222
className="h4 d-flex justify-content-between align-items-center"

0 commit comments

Comments
 (0)