fix: stop mdx ddossing me
This commit is contained in:
parent
b76e524e27
commit
8524db8ecf
3 changed files with 9 additions and 30 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "www-aaronjy-me",
|
||||
"version": "2.1.0",
|
||||
"version": "2.1.1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
|
|
@ -5,33 +5,33 @@ import { useEffect, useState, useTransition } from 'react'
|
|||
export const mdxComponents = {
|
||||
StaticContentList: ({ type, urlPrefix, max = 0 }) => {
|
||||
const [items, setItems] = useState([])
|
||||
const [isLoading, setLoading] = useState(true)
|
||||
const [isLoading, setLoading] = useState(false)
|
||||
|
||||
useEffect(function () {
|
||||
if (!urlPrefix || max <= 0)
|
||||
return;
|
||||
|
||||
switch (type) {
|
||||
case 'posts':
|
||||
(async function () {
|
||||
setLoading(true)
|
||||
const res = await fetchPosts([])
|
||||
const json = await res.json()
|
||||
setItems(json.data.sort((a, b) => a.datePublished < b.datePublished) ?? [])
|
||||
setLoading(false)
|
||||
})()
|
||||
break
|
||||
break;
|
||||
|
||||
default:
|
||||
throw `Could not render StaticContentList: content type ${type} not supported.`
|
||||
}
|
||||
})
|
||||
}, [type, urlPrefix, max])
|
||||
|
||||
return (
|
||||
<>
|
||||
{isLoading && <p>Loading...</p> }
|
||||
|
||||
|
||||
|
||||
{!isLoading && <StaticContentList entries={items} urlPrefix={urlPrefix} max={max} />}
|
||||
</>
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,27 +8,6 @@ import {
|
|||
} from 'next-mdx-remote-client/serialize'
|
||||
import { NextSeo } from 'next-seo'
|
||||
|
||||
// export async function getStaticPaths () {
|
||||
// const res = await fetchBasicPages(['path'])
|
||||
|
||||
// if (!res.ok) {
|
||||
// throw new FailedFetchBasicPagesError(await res.text())
|
||||
// }
|
||||
|
||||
// const pages = (await res.json()).data
|
||||
|
||||
// const paths = {
|
||||
// paths: pages.map(page => ({
|
||||
// params: {
|
||||
// path: page.path?.split('/') // about/page -> [about, page]
|
||||
// .filter(p => !!p) ?? [] // deal with paths starting with '/'
|
||||
// }
|
||||
// })),
|
||||
// fallback: true // false or "blocking"
|
||||
// }
|
||||
|
||||
// return paths
|
||||
// }
|
||||
export async function getServerSideProps ({ params }) {
|
||||
const { path } = params
|
||||
console.log(params)
|
||||
|
|
Loading…
Add table
Reference in a new issue