mirror of
https://github.com/oceanprotocol/market.git
synced 2024-06-30 22:01:44 +02:00
* migrate to Next.js * migrate scripts * generate markdown pages * make all the markdown work * fix profile, fix image loading * git+ssh → git+https, again * bump packages * maybe windows build fix * add public to gitignore Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * Next.js v12! Webpack 5! No build hacks anymore * json import fixes * fixes Co-authored-by: mihaisc <mihai.scarlat@smartcontrol.ro>
65 lines
1.4 KiB
TypeScript
65 lines
1.4 KiB
TypeScript
import React, { ReactElement } from 'react'
|
|
import { getPageBySlug, getAllPages, PageData } from '@utils/markdownPages'
|
|
import Page from '@shared/Page'
|
|
import styles from '@shared/Page/PageMarkdown.module.css'
|
|
import Container from '@shared/atoms/Container'
|
|
import { useRouter } from 'next/router'
|
|
import { markdownToHtml } from '@utils/markdown'
|
|
|
|
export default function PageMarkdown(page: PageData): ReactElement {
|
|
const router = useRouter()
|
|
if (!page || page.content === '') return null
|
|
|
|
const { title, description } = page.frontmatter
|
|
const { content } = page
|
|
|
|
return (
|
|
<Page
|
|
title={title}
|
|
description={description}
|
|
uri={router.asPath}
|
|
headerCenter
|
|
>
|
|
<Container narrow>
|
|
<div
|
|
className={styles.content}
|
|
dangerouslySetInnerHTML={{ __html: content }}
|
|
/>
|
|
</Container>
|
|
</Page>
|
|
)
|
|
}
|
|
|
|
export async function getStaticProps({
|
|
params
|
|
}: {
|
|
params: { slug: string }
|
|
}): Promise<{ props: PageData }> {
|
|
const page = getPageBySlug(params.slug)
|
|
const content = markdownToHtml(page?.content || '')
|
|
|
|
return {
|
|
props: { ...page, content }
|
|
}
|
|
}
|
|
|
|
export async function getStaticPaths(): Promise<{
|
|
paths: {
|
|
params: {
|
|
slug: string
|
|
}
|
|
}[]
|
|
fallback: boolean
|
|
}> {
|
|
const pages = getAllPages()
|
|
|
|
return {
|
|
paths: pages.map((page) => {
|
|
return {
|
|
params: { slug: page.slug }
|
|
}
|
|
}),
|
|
fallback: false
|
|
}
|
|
}
|