slug page fix ts errors
This commit is contained in:
1 parent
39a1f4bb87
commit
7559db5460
1 file changed
+6
-6
+6
-6
@@ -17,13 +17,13 @@ import { FileCard } from '@/components/FIleCard'
|
|||||||
import { Picture } from '@/components/Picture'
|
import { Picture } from '@/components/Picture'
|
||||||
|
|
||||||
async function getUrls() {
|
async function getUrls() {
|
||||||
let urls = []
|
let urls: string[] = []
|
||||||
|
|
||||||
const limit = 100
|
const limit = 100
|
||||||
let start = 0
|
let start = 0
|
||||||
while (true) {
|
while (true) {
|
||||||
const url = `https://hudozka.tmshv.com/pages?_limit=${limit}&_start=${start}`
|
const url = `https://hudozka.tmshv.com/pages?_limit=${limit}&_start=${start}`
|
||||||
const res = await apiGet(createPageUrls)(url, null)
|
const res = await apiGet(createPageUrls)(url, () => ({ items: [] }))
|
||||||
if (!res || res.items.length === 0) {
|
if (!res || res.items.length === 0) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ const Index: NextPage<Props> = props => {
|
|||||||
|
|
||||||
<Page
|
<Page
|
||||||
tags={props.tags}
|
tags={props.tags}
|
||||||
date={props.date ? new Date(props.date) : null}
|
date={props.date ? new Date(props.date) : undefined}
|
||||||
>
|
>
|
||||||
<article className={'article'}>
|
<article className={'article'}>
|
||||||
{props.tokens.map((x, i) => {
|
{props.tokens.map((x, i) => {
|
||||||
@@ -149,9 +149,9 @@ const Index: NextPage<Props> = props => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const getStaticProps: GetStaticProps<Props> = async ctx => {
|
export const getStaticProps: GetStaticProps<Props> = async ctx => {
|
||||||
const slug = paramsToSlug(ctx.params.slug)
|
const slug = paramsToSlug(ctx.params?.slug ?? [])
|
||||||
const url = `https://hudozka.tmshv.com/pages?slug=${slug}`
|
const url = `https://hudozka.tmshv.com/pages?slug=${slug}`
|
||||||
const page = await apiGet(createPage) (url, () => null)
|
const page = await apiGet(createPage)(url, () => null)
|
||||||
if (!page) {
|
if (!page) {
|
||||||
return {
|
return {
|
||||||
notFound: true,
|
notFound: true,
|
||||||
@@ -163,7 +163,7 @@ export const getStaticProps: GetStaticProps<Props> = async ctx => {
|
|||||||
|
|
||||||
const description = page.description ?? undefined
|
const description = page.description ?? undefined
|
||||||
const breadcrumbSize = page?.breadcrumb?.length ?? 0
|
const breadcrumbSize = page?.breadcrumb?.length ?? 0
|
||||||
const breadcrumb = breadcrumbSize < 2 ? null : page.breadcrumb
|
const breadcrumb = breadcrumbSize < 2 ? [] : page.breadcrumb ?? []
|
||||||
const meta = (new MetaBuilder())
|
const meta = (new MetaBuilder())
|
||||||
.setImage(page.cover)
|
.setImage(page.cover)
|
||||||
.setTitle(page.title)
|
.setTitle(page.title)
|
||||||
|
|||||||
Reference in new issue
Block a user