[refactor][xs]: rename docs directory to site reflecting fact this is the full website.

This commit is contained in:
Rufus Pollock
2021-07-28 09:27:17 +02:00
parent bb93103997
commit b81cf992de
25 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
import path from 'path'
import * as fs from 'fs'
import Link from 'next/link'
import Layout from '../../components/layout'
import Prose from '../../components/prose'
import { formatMD } from '../../lib/utils'
export default function Docs({ title, mdFile }) {
return (
<Layout title="Portal.js Documentation - {title}">
<Prose mdFile={mdFile}>
</Prose>
</Layout>
)
}
const postsDirectory = 'markdowns/docs'
export async function getStaticProps({params}) {
const postId = params.id ? params.id : 'index'
const mdFilePath = path.join(postsDirectory, postId + '.md')
const mdFile = await formatMD(mdFilePath)
return {
props: {
mdFile
}
}
}
export async function getStaticPaths() {
const fileNames = fs.readdirSync(postsDirectory)
const paths = fileNames.map(fileName => {
if (fileName == 'index.md') {
return {
params: {
id: null
}
}
} else {
return {
params: {
id: [ fileName.replace(/\.md$/, '') ]
}
}
}
})
return {
paths: paths,
fallback: false
}
}