Skip to content

Commit

Permalink
Remove type from output
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic committed Jul 4, 2024
1 parent 49df406 commit cb0a3d2
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 54 deletions.
3 changes: 0 additions & 3 deletions packages/astro/src/content/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export function createGetCollection({
return [...store.values<DataEntry>(collection)].map((entry) => ({
...entry,
collection,
type: 'experimental_data',
}));
} else {
// eslint-disable-next-line no-console
Expand Down Expand Up @@ -149,7 +148,6 @@ export function createGetEntryBySlug({
return {
...entry,
collection,
type: 'experimental_data',
};
}

Expand Down Expand Up @@ -190,7 +188,6 @@ export function createGetDataEntryById({ getEntryImport }: { getEntryImport: Get
return {
...entry,
collection,
type: 'experimental_data',
};
}

Expand Down
5 changes: 0 additions & 5 deletions packages/astro/test/content-layer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ describe('Content Layer', () => {
title: 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit',
body: 'quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto',
},
type: 'experimental_data',
});
});

Expand Down Expand Up @@ -82,7 +81,6 @@ describe('Content Layer', () => {
assert.deepEqual(json.dataEntry, {
id: 'beagle',
collection: 'dogs',
type: 'experimental_data',
data: {
breed: 'Beagle',
id: 'beagle',
Expand Down Expand Up @@ -110,7 +108,6 @@ describe('Content Layer', () => {
lifespan: '15 years',
temperament: ['Active', 'Affectionate', 'Social', 'Playful'],
},
type: 'experimental_data',
});
});
});
Expand Down Expand Up @@ -143,7 +140,6 @@ describe('Content Layer', () => {
title: 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit',
body: 'quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto',
},
type: 'experimental_data',
});
});

Expand Down Expand Up @@ -192,7 +188,6 @@ describe('Content Layer', () => {
assert.deepEqual(json.dataEntry, {
id: 'beagle',
collection: 'dogs',
type: 'experimental_data',
data: {
breed: 'Beagle',
id: 'beagle',
Expand Down
102 changes: 56 additions & 46 deletions packages/astro/test/fixtures/content-layer/src/content/config.ts
Original file line number Diff line number Diff line change
@@ -1,60 +1,61 @@
import { defineCollection, z } from 'astro:content';
import { file, glob } from "astro/loaders"
import { file, glob } from 'astro/loaders';
import { loader } from '../loaders/post-loader.js';

const blog = defineCollection({
type: "experimental_data",
loader: loader({ url: "https://jsonplaceholder.typicode.com/posts" }),
type: 'experimental_data',
loader: loader({ url: 'https://jsonplaceholder.typicode.com/posts' }),
});

const dogs = defineCollection({
type: "experimental_data",
loader: file("src/data/dogs.json"),
type: 'experimental_data',
loader: file('src/data/dogs.json'),
schema: z.object({
breed: z.string(),
id: z.string(),
size: z.string(),
origin: z.string(),
lifespan: z.string(),
temperament: z.array(z.string())
temperament: z.array(z.string()),
}),
})
});

const cats = defineCollection({
type: "experimental_data",
loader: async function() {
return [{
"breed": "Siamese",
"id": "siamese",
"size": "Medium",
"origin": "Thailand",
"lifespan": "15 years",
"temperament": ["Active", "Affectionate", "Social", "Playful"]
type: 'experimental_data',
loader: async function () {
return [
{
breed: 'Siamese',
id: 'siamese',
size: 'Medium',
origin: 'Thailand',
lifespan: '15 years',
temperament: ['Active', 'Affectionate', 'Social', 'Playful'],
},
{
"breed": "Persian",
"id": "persian",
"size": "Medium",
"origin": "Iran",
"lifespan": "15 years",
"temperament": ["Calm", "Affectionate", "Social"]
{
breed: 'Persian',
id: 'persian',
size: 'Medium',
origin: 'Iran',
lifespan: '15 years',
temperament: ['Calm', 'Affectionate', 'Social'],
},
{
"breed": "Tabby",
"id": "tabby",
"size": "Medium",
"origin": "Egypt",
"lifespan": "15 years",
"temperament": ["Curious", "Playful", "Independent"]
{
breed: 'Tabby',
id: 'tabby',
size: 'Medium',
origin: 'Egypt',
lifespan: '15 years',
temperament: ['Curious', 'Playful', 'Independent'],
},
{
"breed": "Ragdoll",
"id": "ragdoll",
"size": "Medium",
"origin": "United States",
"lifespan": "15 years",
"temperament": ["Calm", "Affectionate", "Social"]
}
breed: 'Ragdoll',
id: 'ragdoll',
size: 'Medium',
origin: 'United States',
lifespan: '15 years',
temperament: ['Calm', 'Affectionate', 'Social'],
},
];
},
schema: z.object({
Expand All @@ -63,18 +64,27 @@ const cats = defineCollection({
size: z.string(),
origin: z.string(),
lifespan: z.string(),
temperament: z.array(z.string())
temperament: z.array(z.string()),
}),
})
});

const spacecraft = defineCollection({
type: "experimental_data",
loader: glob({ pattern: "*", base: "content-outside-src" })
})
type: 'experimental_data',
loader: glob({ pattern: '*', base: 'content-outside-src' }),
});

const numbers = defineCollection({
type: "experimental_data",
loader: glob({pattern: "src/data/glob-data/*", base: "."}),
})
const staff = defineCollection({
type: 'experimental_data',
loader: glob({
pattern: '**/*.md',
base: 'data/staff',
generateId: ({ entry, base, data }) => {
if (data.slug) {
return data.slug as string;
}
return `staff/${entry.slice(0, -3)}`;
},
}),
});

export const collections = { blog, dogs, cats, numbers, spacecraft };

0 comments on commit cb0a3d2

Please sign in to comment.