From 58115bfd11ec7186d682bd52ea0ce3a00b7004b1 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Sat, 13 Sep 2025 15:12:32 +0200 Subject: [PATCH] Dynamic filename finding --- web/pages/constitution.tsx | 3 ++- web/pages/faq.tsx | 3 ++- web/pages/financials.tsx | 3 ++- web/pages/members.tsx | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/web/pages/constitution.tsx b/web/pages/constitution.tsx index 094f437c..5aea3e02 100644 --- a/web/pages/constitution.tsx +++ b/web/pages/constitution.tsx @@ -4,7 +4,7 @@ import fs from 'fs'; import path from 'path'; import MarkdownPage from "web/components/markdown"; -const FILENAME = 'constitution'; +const FILENAME = __filename.split('/').pop()?.split('.').shift(); export async function getStaticProps() { const filePath = path.join(process.cwd(), 'public', 'md', FILENAME + '.md'); @@ -15,5 +15,6 @@ export async function getStaticProps() { type Props = { content: string }; export default function Faq({content}: Props) { + if (!FILENAME) throw new Error('Could not determine filename'); return } diff --git a/web/pages/faq.tsx b/web/pages/faq.tsx index e16482eb..5aea3e02 100644 --- a/web/pages/faq.tsx +++ b/web/pages/faq.tsx @@ -4,7 +4,7 @@ import fs from 'fs'; import path from 'path'; import MarkdownPage from "web/components/markdown"; -const FILENAME = 'faq'; +const FILENAME = __filename.split('/').pop()?.split('.').shift(); export async function getStaticProps() { const filePath = path.join(process.cwd(), 'public', 'md', FILENAME + '.md'); @@ -15,5 +15,6 @@ export async function getStaticProps() { type Props = { content: string }; export default function Faq({content}: Props) { + if (!FILENAME) throw new Error('Could not determine filename'); return } diff --git a/web/pages/financials.tsx b/web/pages/financials.tsx index 0cd4f412..5aea3e02 100644 --- a/web/pages/financials.tsx +++ b/web/pages/financials.tsx @@ -4,7 +4,7 @@ import fs from 'fs'; import path from 'path'; import MarkdownPage from "web/components/markdown"; -const FILENAME = 'financials'; +const FILENAME = __filename.split('/').pop()?.split('.').shift(); export async function getStaticProps() { const filePath = path.join(process.cwd(), 'public', 'md', FILENAME + '.md'); @@ -15,5 +15,6 @@ export async function getStaticProps() { type Props = { content: string }; export default function Faq({content}: Props) { + if (!FILENAME) throw new Error('Could not determine filename'); return } diff --git a/web/pages/members.tsx b/web/pages/members.tsx index a21ef753..5aea3e02 100644 --- a/web/pages/members.tsx +++ b/web/pages/members.tsx @@ -4,7 +4,7 @@ import fs from 'fs'; import path from 'path'; import MarkdownPage from "web/components/markdown"; -const FILENAME = 'members'; +const FILENAME = __filename.split('/').pop()?.split('.').shift(); export async function getStaticProps() { const filePath = path.join(process.cwd(), 'public', 'md', FILENAME + '.md'); @@ -15,5 +15,6 @@ export async function getStaticProps() { type Props = { content: string }; export default function Faq({content}: Props) { + if (!FILENAME) throw new Error('Could not determine filename'); return }