Skip to content

Commit 9292def

Browse files
committed
chore: fix typecheck
1 parent 03cbb34 commit 9292def

File tree

2 files changed

+37
-31
lines changed

2 files changed

+37
-31
lines changed

docs/src/pages/og/[...slug].ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
/* eslint-disable ts/ban-ts-comment */
12
import { OGImageRoute } from 'astro-og-canvas'
23

4+
// @ts-ignore
35
import { paths } from 'node_modules/astro-vitesse/src/utils/routing'
46

5-
const pages = Object.fromEntries(paths.map(({ params: { slug }, props: {
7+
const pages = Object.fromEntries(paths.map(({ params: {
8+
// @ts-ignore
9+
slug,
10+
}, props: {
11+
// @ts-ignore
612
entry,
713
} }) => {
814
return [!slug ? 'index' : slug, entry?.data]

src/components/ListPosts.astro

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
2-
import { CollectionEntry } from 'astro:content'
2+
import type { CollectionEntry, InferEntrySchema } from 'astro:content'
33
import { formatDate } from '../logics'
44
import { slugToLocaleData } from '../utils/slugs'
55
import { ensureLeadingSlash, stripLeadingSlash } from '../utils/path'
6-
import { getLocaleRoutes, Route, VitessePagesEntry } from '../utils/routing'
6+
import { getLocaleRoutes, type Route } from '../utils/routing'
77
import { generateVitessePageRouteData } from '../utils/vitesse-page'
88
99
export interface Props {
1010
startsWith?: string
1111
items?: CollectionEntry<'pages'>['data'][]
1212
}
1313
14-
let { startsWith = 'posts/', items: pagesProps } = Astro.props
14+
const { startsWith = 'posts/', items: pagesProps } = Astro.props
1515
1616
let pagesCollection: Route[] = []
1717
@@ -23,29 +23,29 @@ if (!pagesProps?.length) {
2323
pagesCollection = routes
2424
}
2525
26-
const newPagePros = [...(pagesProps || [])].map(async (page) => {
27-
const { entry, slug, id, entryMeta, dir, lang, locale } = await generateVitessePageRouteData({
28-
url: Astro.url,
29-
props: {
30-
frontmatter: page,
31-
lang: localeData.locale,
32-
},
33-
})
34-
35-
return {
36-
entry,
37-
slug,
38-
id,
39-
entryMeta,
40-
dir,
41-
lang,
42-
locale,
43-
}
44-
})
45-
46-
pagesProps = await Promise.all(newPagePros)
47-
48-
const pages: Route[] = [...((pagesProps.length ? pagesProps : null) || pagesCollection)]
26+
const newPagePros: Route[] = await Promise.all(
27+
[...(pagesProps || [])].map(async (page): Promise<Route> => {
28+
const { entry, slug, id, entryMeta, dir, lang, locale } = await generateVitessePageRouteData({
29+
url: Astro.url,
30+
props: {
31+
frontmatter: page,
32+
lang: localeData.locale,
33+
},
34+
})
35+
36+
return {
37+
entry,
38+
slug,
39+
id,
40+
entryMeta,
41+
dir,
42+
lang,
43+
locale,
44+
}
45+
}),
46+
)
47+
48+
const pages: Route[] = [...((newPagePros.length ? newPagePros : null) || pagesCollection)]
4949
.sort((a, b) => +new Date(b.entry.data.date!) - +new Date(a.entry.data.date!))
5050
.map((page) => ({
5151
...page,
@@ -61,11 +61,11 @@ const pages: Route[] = [...((pagesProps.length ? pagesProps : null) || pagesColl
6161
const getYear = (a: Date | string | number) => new Date(a).getFullYear()
6262
const isFuture = (a?: Date | string | number) => a && new Date(a) > new Date()
6363
const isSameYear = (a?: Date | string | number, b?: Date | string | number) => a && b && getYear(a) === getYear(b)
64-
function isSameGroup(a: VitessePagesEntry, b?: VitessePagesEntry) {
64+
function isSameGroup(a: InferEntrySchema<'pages'>, b?: InferEntrySchema<'pages'>) {
6565
return isFuture(a.date) === isFuture(b?.date) && isSameYear(a.date, b?.date)
6666
}
6767
68-
function getGroupName(p: VitessePagesEntry) {
68+
function getGroupName(p: InferEntrySchema<'pages'>) {
6969
if (isFuture(p.date)) return 'Upcoming'
7070
return getYear(p.date!)
7171
}
@@ -121,8 +121,8 @@ function getGroupName(p: VitessePagesEntry) {
121121
href={data.path}
122122
class="item block font-normal mb-6 mt-2 no-underline"
123123
{...{
124-
target: data.path.startsWith('http') ? '_blank' : undefined,
125-
rel: data.path.startsWith('http') ? 'noopener noreferrer' : undefined,
124+
target: data.path?.startsWith('http') ? '_blank' : undefined,
125+
rel: data.path?.startsWith('http') ? 'noopener noreferrer' : undefined,
126126
}}
127127
>
128128
<li class="no-underline" flex="~ col md:row gap-2 md:items-center">

0 commit comments

Comments
 (0)