[site,#572][s]: refactor existing site content into the content directory.

* Can get rid of existing pages as now our generic markdown / mdx loader at the root \[...slug\].js catches everything
* Convert gallery to a markdown file
This commit is contained in:
Rufus Pollock
2021-07-28 23:23:28 +02:00
parent 8c3b1bccd3
commit 22648a0528
8 changed files with 6 additions and 96 deletions

View File

@@ -1,52 +0,0 @@
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
}
}

View File

@@ -1,13 +0,0 @@
import Layout from '../components/layout'
import Prose from '../components/prose'
export default function Gallery() {
return (
<Layout title="Portal.js Gallery">
<Prose>
<p className="text-center">Come back soon!</p>
</Prose>
</Layout>
)
}

View File

@@ -1,30 +0,0 @@
import Link from 'next/link'
import path from 'path'
import Layout from '../components/layout'
import Prose from '../components/prose'
import { formatMD } from '../lib/utils'
export default function Docs({ mdFile }) {
return (
<Layout title="Portal.js - Learn">
<Prose mdFile={mdFile}>
<p className="text-center">
<Link href="/references">
<button>Next Page</button>
</Link>
</p>
</Prose>
</Layout>
)
}
export async function getStaticProps() {
const mdFilePath = path.join(process.cwd(), "markdowns/tutorial-doc/learn.md")
const mdFile = await formatMD(mdFilePath)
return {
props: {
mdFile
}
}
}