temp re-added collection and remove to imports of GetStaticPaths. Testing using cloudflare pages build
This commit is contained in:
parent
c21e3e2a9b
commit
1bd58dc9d4
|
@ -192,7 +192,15 @@ declare module 'astro:content' {
|
|||
};
|
||||
|
||||
type DataEntryMap = {
|
||||
|
||||
"countries": Record<string, {
|
||||
id: string;
|
||||
body?: string;
|
||||
collection: "countries";
|
||||
data: InferEntrySchema<"countries">;
|
||||
rendered?: RenderedContent;
|
||||
filePath?: string;
|
||||
}>;
|
||||
|
||||
};
|
||||
|
||||
type AnyEntryMap = ContentEntryMap & DataEntryMap;
|
||||
|
|
|
@ -18,7 +18,6 @@ const countries = defineCollection({
|
|||
loader: async () => {
|
||||
const response = await fetch('https://restcountries.com/v3.1/all')
|
||||
const data = await response.json()
|
||||
console.log('🚀 ~ loader: ~ data:', data)
|
||||
|
||||
// Must return an array of entries with an id property, or an object with IDs as keys and entries as values
|
||||
return data.map((country: any) => ({
|
||||
|
@ -125,4 +124,4 @@ const countries = defineCollection({
|
|||
})
|
||||
|
||||
// export const collections = { countries, blog }
|
||||
export const collections = { blog }
|
||||
export const collections = { blog, countries }
|
||||
|
|
|
@ -9,7 +9,6 @@ import FormattedDate from '../../components/FormattedDate.astro'
|
|||
const posts = (await getCollection('blog')).sort(
|
||||
(a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf()
|
||||
)
|
||||
console.log('🚀 ~ posts', posts)
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
---
|
||||
// src/pages/countries/[id].astro
|
||||
import type { GetStaticPaths } from 'astro'
|
||||
import { getCollection } from 'astro:content'
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const collection = await getCollection('countries')
|
||||
console.log(
|
||||
'🚀 ~ constgetStaticPaths:GetStaticPaths= ~ collection:',
|
||||
collection
|
||||
)
|
||||
if (!collection) return []
|
||||
return collection.map((country) => ({
|
||||
params: {
|
||||
|
|
|
@ -8,7 +8,6 @@ import type { GetStaticPaths } from 'astro'
|
|||
import { getCollection } from 'astro:content'
|
||||
|
||||
const countries = await getCollection('countries')
|
||||
console.log('🚀 ~ countries:', countries)
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
|
|
Loading…
Reference in New Issue