diff --git a/package.json b/package.json index 624668f..4d01bee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "www-aaronjy-me", - "version": "2.1.0", + "version": "2.1.1", "private": true, "type": "module", "scripts": { diff --git a/src/lib/mdx-components.js b/src/lib/mdx-components.js index 2f59a51..d4fd3cc 100644 --- a/src/lib/mdx-components.js +++ b/src/lib/mdx-components.js @@ -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 &&
Loading...
} - - - + {isLoading &&Loading...
} {!isLoading &&