temp re-added collection and remove to imports of GetStaticPaths. Testing using cloudflare pages build

This commit is contained in:
Robert McGovern 2024-11-05 22:29:43 +00:00
parent c21e3e2a9b
commit 1bd58dc9d4
5 changed files with 10 additions and 10 deletions

8
.astro/content.d.ts vendored
View File

@ -192,6 +192,14 @@ declare module 'astro:content' {
};
type DataEntryMap = {
"countries": Record<string, {
id: string;
body?: string;
collection: "countries";
data: InferEntrySchema<"countries">;
rendered?: RenderedContent;
filePath?: string;
}>;
};

View File

@ -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 }

View File

@ -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>

View File

@ -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: {

View File

@ -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>