From a85c72352444340a974e88fc06c9ea113a157d09 Mon Sep 17 00:00:00 2001 From: Evangelos Vatikiotis Date: Tue, 2 Jul 2024 00:32:29 +0200 Subject: [PATCH 1/2] changed content of home pages --- src/pages/advice/[pid].tsx | 29 +++++++++++++++++++++ src/pages/advice/index.tsx | 49 ++++++++++++++++++++++++++++++++++++ src/pages/articles/index.tsx | 2 +- 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 src/pages/advice/[pid].tsx create mode 100644 src/pages/advice/index.tsx diff --git a/src/pages/advice/[pid].tsx b/src/pages/advice/[pid].tsx new file mode 100644 index 0000000..5a30de6 --- /dev/null +++ b/src/pages/advice/[pid].tsx @@ -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 ( + {props.article} + ); +} + +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 } + + } + + + diff --git a/src/pages/advice/index.tsx b/src/pages/advice/index.tsx new file mode 100644 index 0000000..4c60078 --- /dev/null +++ b/src/pages/advice/index.tsx @@ -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 ( + <> +
+
+ + + + + + + + + + {articles.map((article: any, index: any) => ( + + ))} + +
+ {" "} + #{" "} + article Name Created Date
+
+
+ + ); +} +// 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); + } + } \ No newline at end of file diff --git a/src/pages/articles/index.tsx b/src/pages/articles/index.tsx index 4c60078..d345dd5 100644 --- a/src/pages/articles/index.tsx +++ b/src/pages/articles/index.tsx @@ -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) { From 438d44a15a3e624ad64e5c4100bfefed0dd38f24 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 08:38:28 +0000 Subject: [PATCH 2/2] Bump typescript from 5.4.5 to 5.5.4 Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.4.5 to 5.5.4. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml) - [Commits](https://github.com/Microsoft/TypeScript/compare/v5.4.5...v5.5.4) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5c0482a..ff9f6ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,7 +29,7 @@ "husky": "^9.0.11", "lint-staged": "^15.2.5", "prettier": "^3.2.5", - "typescript": "5.4.5" + "typescript": "5.5.4" } }, "node_modules/@babel/runtime": { @@ -4345,9 +4345,9 @@ } }, "node_modules/typescript": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", - "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", "dev": true, "bin": { "tsc": "bin/tsc", diff --git a/package.json b/package.json index 8eb4f12..e405286 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "husky": "^9.0.11", "lint-staged": "^15.2.5", "prettier": "^3.2.5", - "typescript": "5.4.5" + "typescript": "5.5.4" }, "lint-staged": { "src/**/*.{ts,tsx}": "npm run lint:fix"