|
1 | 1 | import Head from "next/head" |
2 | | -import { resolve } from "node:path" |
3 | | -import { readdir, readFile } from "node:fs/promises" |
4 | 2 | import { FormattedMessage, useIntl } from "react-intl" |
5 | | -import matter from "gray-matter" |
6 | 3 | import { InferGetStaticPropsType } from "next" |
7 | | -import z from "zod" |
8 | 4 | import Markdown from "react-markdown" |
9 | 5 |
|
10 | 6 | import Hero from "../components/Hero" |
11 | 7 | import Layout from "../components/Layout" |
12 | 8 | import { RoadmapStatus } from "../components/RoadmapStatus" |
13 | 9 | import { withDefaultStaticProps } from "../utils/defaultStaticProps" |
| 10 | +import { loadRoadmap } from "../utils/roadmap" |
14 | 11 |
|
15 | 12 | const Roadmap = ({ |
16 | 13 | features, |
@@ -102,27 +99,8 @@ const allowedElements: ReadonlyArray<string> = [ |
102 | 99 | "li", |
103 | 100 | ] |
104 | 101 |
|
105 | | -const featureSchema = z.object({ |
106 | | - data: z.object({ |
107 | | - title: z.string(), |
108 | | - status: z.enum(["exploring", "working", "next", "released"]), |
109 | | - }), |
110 | | - content: z.string().trim(), |
111 | | -}) |
112 | | - |
113 | 102 | export const getStaticProps = withDefaultStaticProps(async () => { |
114 | | - const files = await readdir(resolve(process.cwd(), "data/roadmap")) |
115 | | - const features = await Promise.all( |
116 | | - files |
117 | | - .filter((file) => file.endsWith(".md")) |
118 | | - .map(async (file) => { |
119 | | - const contents = await readFile( |
120 | | - resolve(process.cwd(), "data/roadmap", file), |
121 | | - "utf-8" |
122 | | - ) |
123 | | - return featureSchema.parse(matter(contents)) |
124 | | - }) |
125 | | - ) |
| 103 | + const features = await loadRoadmap() |
126 | 104 | return { |
127 | 105 | props: { features }, |
128 | 106 | } |
|
0 commit comments