Skip to content

Commit

Permalink
changed content of home pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelos Vatikiotis committed Jul 1, 2024
1 parent 6b89e3c commit a85c723
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
29 changes: 29 additions & 0 deletions src/pages/advice/[pid].tsx
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 }

}



49 changes: 49 additions & 0 deletions src/pages/advice/index.tsx
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);
}
}
2 changes: 1 addition & 1 deletion src/pages/articles/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function ArticlesList(props: any) {
// 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")}};
return {props: {articles: await readDirectory("./src/markdown-pages/advice")}};
}

async function readDirectory(path: any) {
Expand Down

0 comments on commit a85c723

Please sign in to comment.