diff --git a/components/wiki/PageBody.tsx b/components/wiki/PageBody.tsx
index 107e08c..ade3dff 100644
--- a/components/wiki/PageBody.tsx
+++ b/components/wiki/PageBody.tsx
@@ -3,14 +3,21 @@ import RenderMarkdown from "./RenderMarkdown";
interface PageBodyProps {
children: string;
+ currentLanguage: string;
+ path: string;
}
-export default function PageBody({ children }: PageBodyProps) {
+export default function PageBody(props: PageBodyProps) {
return (
- {children}
+
+ {props.children}
+
diff --git a/components/wiki/RenderMarkdown.tsx b/components/wiki/RenderMarkdown.tsx
index 54891f2..4b62cda 100644
--- a/components/wiki/RenderMarkdown.tsx
+++ b/components/wiki/RenderMarkdown.tsx
@@ -7,24 +7,54 @@ import remarkGfm from "remark-gfm";
interface RenderMarkdownProps {
children: string;
+ path: string;
+ currentLanguage: string;
}
-export default function RenderMarkdown({ children }: RenderMarkdownProps) {
+export default function RenderMarkdown(pageprops: RenderMarkdownProps) {
return (
{
+ // if the link is internal, reformat it; if it ends with a slash, do not apply this
+ let href = props.href as string;
+ if (!href.endsWith("/") && !href.startsWith("http")) {
+ if (href.startsWith("/wiki/")) {
+ href = `/wiki/${pageprops.currentLanguage}${href.slice(5)}`;
+ } else {
+ // if single relative
+ href = `/wiki/${pageprops.currentLanguage}/${pageprops.path}/${href}`;
+ }
+ }
return (
-
- {props.children ? props.children[0] : props.href}
+
+ {props.children ? props.children[0] : href}
);
},
+ img: ({ node, ...props }) => {
+ // if image is internal (relative), prefix it with the current page's path
+ let src = props.src as string;
+ if (!src.startsWith("http") && !src.startsWith("/")) {
+ src = `/img/wiki/${pageprops.path}/${src}`;
+ }
+ return (
+
+
+
{props.title as string}
+
+ );
+ },
}}
>
- {children}
+ {pageprops.children}
);
}
diff --git a/interfaces/WikiPage.ts b/interfaces/WikiPage.ts
index f09de46..f3ecbd4 100644
--- a/interfaces/WikiPage.ts
+++ b/interfaces/WikiPage.ts
@@ -2,6 +2,8 @@ export default interface WikiPage {
slug: string;
layout?: string;
content: string;
+ language: string;
+ path: string;
data: {
layout?: string;
};
diff --git a/pages/wiki/[...slug]/index.tsx b/pages/wiki/[...slug]/index.tsx
index 9e48730..8bdd9cd 100644
--- a/pages/wiki/[...slug]/index.tsx
+++ b/pages/wiki/[...slug]/index.tsx
@@ -20,11 +20,16 @@ interface TableOfContentsItem {
function WikiLandingPage(props: WikiLandingPageProps) {
const [wikiContent, setWikiContent] = useState(<>>);
const [indexContent, setIndexContent] = useState([]);
+ const [showMobileIndex, setShowMobileIndex] = useState(false);
// needed for proper hydration due to replacing some elements
useEffect(() => {
- setWikiContent({props.page.content});
- }, [props.page.content]);
+ setWikiContent(
+
+ {props.page.content}
+
+ );
+ }, [props.page.content, props.page.language, props.page.path]);
useEffect(() => {
const toc: TableOfContentsItem[] = [];
@@ -39,7 +44,6 @@ function WikiLandingPage(props: WikiLandingPageProps) {
}
});
setIndexContent(toc);
- console.log(toc);
}, [wikiContent]);
return (
@@ -71,6 +75,62 @@ function WikiLandingPage(props: WikiLandingPageProps) {
+ {/* Mobile "Side"-bar */}
+
+
+
setShowMobileIndex(!showMobileIndex)}
+ >
+
Contents
+
+
+
+
+
+ {indexContent.map((item) => {
+ return (
+ // increase indent based on heading level
+
+ );
+ })}
+
+
+
+ {/* Main content */}