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",
|
"name": "www-aaronjy-me",
|
||||||
"version": "2.1.0",
|
"version": "2.1.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -5,33 +5,33 @@ import { useEffect, useState, useTransition } from 'react'
|
||||||
export const mdxComponents = {
|
export const mdxComponents = {
|
||||||
StaticContentList: ({ type, urlPrefix, max = 0 }) => {
|
StaticContentList: ({ type, urlPrefix, max = 0 }) => {
|
||||||
const [items, setItems] = useState([])
|
const [items, setItems] = useState([])
|
||||||
const [isLoading, setLoading] = useState(true)
|
const [isLoading, setLoading] = useState(false)
|
||||||
|
|
||||||
useEffect(function () {
|
useEffect(function () {
|
||||||
|
if (!urlPrefix || max <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'posts':
|
case 'posts':
|
||||||
(async function () {
|
(async function () {
|
||||||
|
setLoading(true)
|
||||||
const res = await fetchPosts([])
|
const res = await fetchPosts([])
|
||||||
const json = await res.json()
|
const json = await res.json()
|
||||||
setItems(json.data.sort((a, b) => a.datePublished < b.datePublished) ?? [])
|
setItems(json.data.sort((a, b) => a.datePublished < b.datePublished) ?? [])
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
})()
|
})()
|
||||||
break
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw `Could not render StaticContentList: content type ${type} not supported.`
|
throw `Could not render StaticContentList: content type ${type} not supported.`
|
||||||
}
|
}
|
||||||
})
|
}, [type, urlPrefix, max])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{isLoading && <p>Loading...</p> }
|
{isLoading && <p>Loading...</p> }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{!isLoading && <StaticContentList entries={items} urlPrefix={urlPrefix} max={max} />}
|
{!isLoading && <StaticContentList entries={items} urlPrefix={urlPrefix} max={max} />}
|
||||||
</>
|
</>
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,27 +8,6 @@ import {
|
||||||
} from 'next-mdx-remote-client/serialize'
|
} from 'next-mdx-remote-client/serialize'
|
||||||
import { NextSeo } from 'next-seo'
|
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 }) {
|
export async function getServerSideProps ({ params }) {
|
||||||
const { path } = params
|
const { path } = params
|
||||||
console.log(params)
|
console.log(params)
|
||||||
|
|
Loading…
Add table
Reference in a new issue