-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
436 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"evolu.me": minor | ||
--- | ||
|
||
Add changelog page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { promises as fs } from "fs"; | ||
import type { GetStaticProps, InferGetStaticPropsType } from "next"; | ||
import path from "path"; | ||
import Markdown from "react-markdown"; | ||
import { PageWithTitle } from "../../components/PageWithTitle"; | ||
import { Text } from "../../components/Text"; | ||
import { create } from "@stylexjs/stylex"; | ||
|
||
export const getStaticProps = (async () => { | ||
const rawMarkdown = await fs.readFile( | ||
path.join(process.cwd(), "CHANGELOG.md"), | ||
"utf8", | ||
); | ||
|
||
const markdown = rawMarkdown | ||
.replace("# evolu.me", "") | ||
.replaceAll("### Minor Changes", "") | ||
.replace(/[a-zA-Z0-9]{7}: /g, "") | ||
.trim(); | ||
|
||
return { | ||
props: { | ||
markdown, | ||
}, | ||
}; | ||
}) satisfies GetStaticProps<{ | ||
markdown: string; | ||
}>; | ||
|
||
export default function Changelog({ | ||
markdown, | ||
}: InferGetStaticPropsType<typeof getStaticProps>) { | ||
return ( | ||
<PageWithTitle title="Changelog"> | ||
<Markdown | ||
components={{ | ||
h2({ children }) { | ||
return ( | ||
<Text tag="h3" style={styles.p}> | ||
{children} | ||
</Text> | ||
); | ||
}, | ||
ul({ children }) { | ||
return <>{children}</>; | ||
}, | ||
li({ children }) { | ||
return ( | ||
<Text tag="p" style={styles.p}> | ||
{children} | ||
</Text> | ||
); | ||
}, | ||
p({ children }) { | ||
if (typeof children !== "string") return null; | ||
return <>{children.trim()}</>; | ||
}, | ||
}} | ||
> | ||
{markdown} | ||
</Markdown> | ||
</PageWithTitle> | ||
); | ||
} | ||
|
||
const styles = create({ | ||
p: { | ||
whiteSpace: "normal", | ||
}, | ||
}); |
Oops, something went wrong.