feat(frontend): add static page support at /page/[name], add tos + privacy link to login
This commit is contained in:
parent
17cc57a31d
commit
78d6a817ed
4 changed files with 51 additions and 2 deletions
|
@ -8,6 +8,7 @@ import TextInput from "../../components/TextInput";
|
|||
import Loading from "../../components/Loading";
|
||||
import Button, { ButtonStyle } from "../../components/Button";
|
||||
import Notice from "../../components/Notice";
|
||||
import BlueLink from "../../components/BlueLink";
|
||||
|
||||
interface CallbackResponse {
|
||||
has_account: boolean;
|
||||
|
@ -191,8 +192,9 @@ export default function Discord() {
|
|||
</span>
|
||||
<span className="block px-3 pb-3">
|
||||
<span className="font-bold">Note:</span> by clicking "Create
|
||||
account", you agree to the terms of service and the privacy
|
||||
policy.
|
||||
account", you agree to the{" "}
|
||||
<BlueLink to="/page/tos">terms of service</BlueLink> and the{" "}
|
||||
<BlueLink to="/page/privacy">privacy policy</BlueLink>.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
43
frontend/pages/page/[page].tsx
Normal file
43
frontend/pages/page/[page].tsx
Normal file
|
@ -0,0 +1,43 @@
|
|||
import { GetStaticProps } from "next";
|
||||
import { readdirSync } from "fs";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
import { readFile } from "fs/promises";
|
||||
import { join } from "path";
|
||||
import Head from "next/head";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const names = readdirSync("./static_pages").filter((name) =>
|
||||
name.endsWith(".md")
|
||||
);
|
||||
|
||||
const paths = names.map((name) => ({
|
||||
params: { page: name.slice(0, -3) },
|
||||
}));
|
||||
|
||||
return {
|
||||
paths: paths,
|
||||
fallback: false,
|
||||
};
|
||||
}
|
||||
|
||||
export const getStaticProps: GetStaticProps<{ text: string }> = async ({
|
||||
params,
|
||||
}) => {
|
||||
const text = await readFile(join("./static_pages", params!.page + ".md"));
|
||||
return { props: { text: text.toString("utf8") } };
|
||||
};
|
||||
|
||||
export default function Page(props: { text: string }) {
|
||||
const title = props.text.split("\n")[0].slice(2);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title key="title">{`${title} - pronouns.cc`}</title>
|
||||
</Head>
|
||||
<div className="prose prose-slate dark:prose-invert">
|
||||
<ReactMarkdown>{props.text}</ReactMarkdown>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
3
frontend/static_pages/.empty
Normal file
3
frontend/static_pages/.empty
Normal file
|
@ -0,0 +1,3 @@
|
|||
Put any static pages here, in markdown format.
|
||||
|
||||
The frontend requires `tos.md` and `privacy.md`, but you can add others if you wish.
|
1
frontend/static_pages/.gitignore
vendored
Normal file
1
frontend/static_pages/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.md
|
Loading…
Reference in a new issue