Skip to content

Commit

Permalink
Move articles
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcticFqx committed Mar 7, 2023
1 parent 1dad4ba commit 0941f26
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/pages/articles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ export default function ListDocs({articles}: ListDocsProps) {

export const getStaticProps = async () => {
const fs = await import('fs');
const files = fs.readdirSync('./articles')
const files = fs.readdirSync('./content/articles')
.filter((file) => file.endsWith('mdx'));
const modules = await Promise.all(
files.map((file) => import(`../../articles/${file}`))
files.map((file) => import(`#/articles/${file}`))
);
const articles = modules.map((mod, index) => {
const file = files[index] as string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { GetStaticProps } from "next";
import { lazy, Suspense } from "react";
import { NavBar } from "@/components/NavBar";

type SlugProps = {page: string, name: string};
type ArticleProps = {page: string, name: string};

export default function Slug({page, name}: SlugProps) {
const MDX = lazy(() => import(`../../../articles/${page}.mdx`));
export default function Article({page, name}: ArticleProps) {
const MDX = lazy(() => import(`#/articles/${page}.mdx`));

return (<>
<h1 className="text-5xl">{name}</h1>
Expand All @@ -20,22 +20,22 @@ export default function Slug({page, name}: SlugProps) {

export async function getStaticPaths() {
const fs = await import('fs');
const files = fs.readdirSync('./articles')
const files = fs.readdirSync('./content/articles')
.filter((file) => file.endsWith('mdx'));
return {
paths: files.map(name => ({
params: {
slug: name.substring(0, name.length-4)
article: name.substring(0, name.length-4)
}
})),
fallback: true,
}
}

type PageStaticProps = GetStaticProps<SlugProps>;
type PageStaticProps = GetStaticProps<ArticleProps>;
export const getStaticProps: PageStaticProps = async ({params}) => {
const file = (`${params?.slug}`);
const mdx = await import(`../../../articles/${file}.mdx`);
const file = (`${params?.article}`);
const mdx = await import(`#/articles/${file}.mdx`);
return {
props: {
page: file,
Expand Down
1 change: 1 addition & 0 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export default function Home() {
return (<>
<h1 className="text-5xl">Chocobois</h1>
<NavBar />
<p>We make game</p>
</>);
}
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"incremental": true,
"noUncheckedIndexedAccess": true,
"paths": {
"@/*": ["./src/*"]
"@/*": ["./src/*"],
"#/*": ["./content/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.cjs", "**/*.mjs", "src"],
Expand Down

0 comments on commit 0941f26

Please sign in to comment.