feat: get to displaying markdown copy
This commit is contained in:
@@ -1,14 +0,0 @@
|
|||||||
.container {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
width: 100%;
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.copy {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.example {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
import styles from './Article.module.css';
|
|
||||||
|
|
||||||
export default function Article() {
|
|
||||||
return (
|
|
||||||
<article className={styles.container}>
|
|
||||||
<section className={styles.copy}>
|
|
||||||
This is the copy
|
|
||||||
</section>
|
|
||||||
<section className={styles.example}>
|
|
||||||
This is the example
|
|
||||||
</section>
|
|
||||||
</article>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -2,8 +2,10 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0 1rem;
|
padding: 1rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
max-width: 1450px;
|
||||||
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.navList {
|
.navList {
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
gap: 1rem;
|
||||||
|
border-bottom: 1px solid #848586;
|
||||||
|
padding: 5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 1000px) {
|
||||||
|
.container {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.container>article {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import styles from './Section.module.css';
|
||||||
|
|
||||||
|
export default function Section({
|
||||||
|
copy,
|
||||||
|
example,
|
||||||
|
}: {
|
||||||
|
copy: string;
|
||||||
|
example: string;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<section
|
||||||
|
className={styles.container}
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: `${copy}${example}`,
|
||||||
|
}}
|
||||||
|
></section>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -14,13 +14,11 @@ function TreeNode({ doc }: { doc: DocsStructure }) {
|
|||||||
return (
|
return (
|
||||||
<li className={styles.listItem}>
|
<li className={styles.listItem}>
|
||||||
{hasChildren ? (
|
{hasChildren ? (
|
||||||
<div className={styles.expandable}>
|
<div
|
||||||
<a
|
onClick={() => setIsExpanded(!isExpanded)}
|
||||||
onClick={() => setIsExpanded(!isExpanded)}
|
className={styles.expandable}
|
||||||
className={styles.link}
|
>
|
||||||
>
|
<a className={styles.link}>{doc.title}</a>
|
||||||
{doc.title}
|
|
||||||
</a>
|
|
||||||
{isExpanded ? (
|
{isExpanded ? (
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
|||||||
@@ -25,7 +25,4 @@ body {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 1450px;
|
|
||||||
margin: 0 auto;
|
|
||||||
padding: 20px;
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
.container {
|
.container {
|
||||||
margin: 0 auto;
|
|
||||||
max-width: 1450px;
|
max-width: 1450px;
|
||||||
padding: 5rem;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
+75
-2
@@ -1,10 +1,83 @@
|
|||||||
import Article from './components/Article';
|
import { versionTwo } from '@/docs/version_002/docsStructure';
|
||||||
|
import Markdoc from '@markdoc/markdoc';
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import Section from './components/Section';
|
||||||
import styles from './page.module.css';
|
import styles from './page.module.css';
|
||||||
|
import { DocsStructure } from './types/types';
|
||||||
|
|
||||||
|
type Section = {
|
||||||
|
title: string;
|
||||||
|
copy: string;
|
||||||
|
example: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
function loadSections(
|
||||||
|
docs: DocsStructure[],
|
||||||
|
sections: Section[] = []
|
||||||
|
): Section[] {
|
||||||
|
for (const doc of docs) {
|
||||||
|
try {
|
||||||
|
const copyPath = path.join(
|
||||||
|
process.cwd(),
|
||||||
|
'src/docs',
|
||||||
|
'version_002',
|
||||||
|
doc.folder,
|
||||||
|
doc.copy!
|
||||||
|
);
|
||||||
|
|
||||||
|
const examplePath = path.join(
|
||||||
|
process.cwd(),
|
||||||
|
'src/docs',
|
||||||
|
'version_002',
|
||||||
|
doc.folder,
|
||||||
|
doc.example!
|
||||||
|
);
|
||||||
|
|
||||||
|
const copySource = fs.readFileSync(copyPath, 'utf8');
|
||||||
|
const exampleSource = fs.readFileSync(
|
||||||
|
examplePath,
|
||||||
|
'utf8'
|
||||||
|
);
|
||||||
|
|
||||||
|
const copyAst = Markdoc.parse(copySource);
|
||||||
|
const exampleAst = Markdoc.parse(exampleSource);
|
||||||
|
const copyContent = Markdoc.transform(copyAst);
|
||||||
|
const exampleContent = Markdoc.transform(exampleAst);
|
||||||
|
const copyHtml = Markdoc.renderers.html(copyContent);
|
||||||
|
const exampleHtml =
|
||||||
|
Markdoc.renderers.html(exampleContent);
|
||||||
|
|
||||||
|
sections.push({
|
||||||
|
title: doc.title,
|
||||||
|
copy: copyHtml,
|
||||||
|
example: exampleHtml,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (doc.children && doc.children.length > 0) {
|
||||||
|
loadSections(doc.children, sections);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sections;
|
||||||
|
}
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
|
const versionTwoSections = loadSections(versionTwo);
|
||||||
|
console.log(versionTwoSections);
|
||||||
return (
|
return (
|
||||||
<main className={styles.container}>
|
<main className={styles.container}>
|
||||||
<Article />
|
{versionTwoSections.map(article => (
|
||||||
|
<Section
|
||||||
|
key={article.title}
|
||||||
|
copy={article.copy}
|
||||||
|
example={article.example}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Authentication
|
||||||
|
|
||||||
|
This is the copy for the authentication page.
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Example
|
||||||
|
|
||||||
|
This is an example for the authentication page.
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Introduction
|
||||||
|
|
||||||
|
This is the copy for the introduction page.
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{% .custom-class-name-here %}
|
||||||
|
|
||||||
|
# Example
|
||||||
|
|
||||||
|
This is the example for the introduction page.
|
||||||
|
|||||||
Reference in New Issue
Block a user