-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Evangelos Vatikiotis
committed
Jul 1, 2024
1 parent
6b89e3c
commit a85c723
Showing
3 changed files
with
79 additions
and
1 deletion.
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,29 @@ | ||
import Markdown from 'react-markdown' | ||
import { promises as fs } from 'fs'; | ||
import 'katex/dist/katex.min.css' | ||
|
||
|
||
|
||
|
||
export default function Article(props:any) { | ||
return ( | ||
<Markdown>{props.article}</Markdown> | ||
); | ||
} | ||
|
||
export async function getStaticProps({params}:{params:any}) { | ||
const article = await fs.readFile("./src/markdown-pages/articles/"+params.pid, "utf8"); | ||
console.log(article) | ||
return {props: {article}}; | ||
|
||
} | ||
|
||
export async function getStaticPaths() { | ||
let paths = (await fs.readdir("./src/markdown-pages/articles")).map(p => "/articles/"+p) | ||
console.log("psths to render:", paths); | ||
return { paths, fallback: true } | ||
|
||
} | ||
|
||
|
||
|
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,49 @@ | ||
import ArticleListItem from "../../components/ArticleListItem"; | ||
import { promises as fs } from 'fs'; | ||
|
||
|
||
export default function ArticlesList(props: any) { | ||
// eslint-disable-next-line react/prop-types | ||
const {articles} = props; | ||
return ( | ||
<> | ||
<div> | ||
<div> | ||
<table className="table"> | ||
<thead> | ||
<tr> | ||
<th className="display-none-small-screen" scope="col"> | ||
{" "} | ||
#{" "} | ||
</th> | ||
<th scope="col"> article Name</th> | ||
<th scope="col"> Created Date</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{articles.map((article: any, index: any) => ( | ||
<ArticleListItem key={article} article={article} index={index}/> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
} | ||
// This function gets called at build time on server-side. | ||
// It won't be called on client-side, so you can even do | ||
// direct database queries. See the "Technical details" section. | ||
export async function getStaticProps() { | ||
return {props: {articles: await readDirectory("./src/markdown-pages/articles")}}; | ||
} | ||
|
||
async function readDirectory(path: any) { | ||
try { | ||
// const data = await fs.readFile(path, 'utf8'); | ||
return await fs.readdir(path); | ||
|
||
} catch (err) { | ||
console.error(err); | ||
} | ||
} |
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