Fixed content collections
This commit is contained in:
parent
c94fb25aba
commit
65d4339b9f
12 changed files with 67 additions and 111 deletions
src/pages/database
|
@ -1,15 +1,10 @@
|
|||
---
|
||||
import { getCollection } from 'astro:content';
|
||||
import TaShowcaseLayout from '../../layouts/taShowcaseLayout.astro'
|
||||
import type { GlobAny } from '../../types/generic'
|
||||
import { findSlug } from '../../utils/tools'
|
||||
|
||||
export function getStaticPaths() {
|
||||
const fulldata = import.meta.glob<GlobAny>(
|
||||
`/src/content/data/*.json`
|
||||
)
|
||||
const keylist = Object.keys(fulldata).map((item) => findSlug(item)!)
|
||||
|
||||
return keylist.map((slug) => ({ params: { slug } }))
|
||||
export async function getStaticPaths() {
|
||||
const fulldata = (await getCollection('taInfoData')).map((data) => data.id)
|
||||
return fulldata.map((slug) => ({ params: { slug } }))
|
||||
}
|
||||
|
||||
const { slug } = Astro.params
|
||||
|
|
|
@ -1,28 +1,20 @@
|
|||
---
|
||||
import { getCollection } from 'astro:content';
|
||||
import Layout from '../../layouts/Layout.astro'
|
||||
import QuestListing from '../../components/questListing.astro'
|
||||
import DatabaseSection from '../../layouts/databaseSection.astro'
|
||||
import { findSlug } from '../../utils/tools'
|
||||
import type { GlobFiledata } from '../../types/generic'
|
||||
|
||||
const description = 'FGO NA TA Database'
|
||||
const fulldata = await getCollection('taInfoData')
|
||||
|
||||
const questInfo = []
|
||||
const fulldata = import.meta.glob<GlobFiledata>(
|
||||
`/src/content/data/*.json`
|
||||
fulldata.sort(
|
||||
(a, b) => Date.parse(b.data.info.questReleaseDate) - Date.parse(a.data.info.questReleaseDate) || b.data.info.fightNumber - a.data.info.fightNumber
|
||||
)
|
||||
const infodata = fulldata.map((quest) => ({
|
||||
...quest.data.info,
|
||||
slug: quest.id
|
||||
}))
|
||||
|
||||
for (const [key, value] of Object.entries(fulldata)) {
|
||||
const url = `/database/${findSlug(key)}`
|
||||
questInfo.push({
|
||||
...(await value())['default'].info,
|
||||
url: url,
|
||||
})
|
||||
}
|
||||
|
||||
questInfo.sort(
|
||||
(a, b) => Date.parse(b.questReleaseDate) - Date.parse(a.questReleaseDate) || b.fightNumber - a.fightNumber
|
||||
)
|
||||
---
|
||||
|
||||
<Layout
|
||||
|
@ -31,7 +23,7 @@ questInfo.sort(
|
|||
descriptionOverride={description}
|
||||
>
|
||||
<DatabaseSection title="FGO NA TA Database">
|
||||
{questInfo.map((quest) => <QuestListing {...quest} />)}
|
||||
{infodata.map((quest) => <QuestListing { ...quest } />)}
|
||||
</DatabaseSection>
|
||||
</Layout>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue