Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data collections and references #6850

Merged
merged 135 commits into from
May 17, 2023
Merged

Data collections and references #6850

merged 135 commits into from
May 17, 2023

Conversation

bholmesdev
Copy link
Contributor

@bholmesdev bholmesdev commented Apr 14, 2023

Demo

Visual.Studio.Code.-.config.ts.with-data.-.2.May.2023.mp4

Implementation for the data collection and collection reference RFCs: withastro/roadmap#569

Changes

Introducing data collections! These are JSON-based collections you can query throughout your app, and "reference" from existing content collections.

  • Introduce a reserved src/data/ directory for storing collections of JSON entries. This uses the same file-based conventions as content collections.
  • Add a new type: 'data' property to defineCollection to configure a data collection from your src/content/config.ts.
  • Add a new query API to fetch data and content entries by ID: getEntry(). Data collections do not have slugs, so we cannot use the existing getEntryBySlug() helper.
  • Add a new reference() extension function to any configured collection. This can be used like a table join in a database, referencing other collections by key.

Testing

  • Test data collections
  • Test collection references
  • Test mixed content errors on sync

Docs

withastro/docs#3233

@changeset-bot
Copy link

changeset-bot bot commented Apr 14, 2023

🦋 Changeset detected

Latest commit: c8a715a

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@bholmesdev bholmesdev changed the title Feat/data collections Data collections and references Apr 14, 2023
@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) pkg: example Related to an example package (scope) pkg: integration Related to any renderer integration (scope) labels Apr 14, 2023
@bholmesdev bholmesdev force-pushed the feat/data-collections branch from 4f5503b to e34e28a Compare April 14, 2023 23:08
@bholmesdev
Copy link
Contributor Author

!preview data-collections

@github-actions github-actions bot added the semver: minor Change triggers a `minor` release label Apr 18, 2023
@github-actions
Copy link
Contributor

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

@bholmesdev bholmesdev force-pushed the feat/data-collections branch from 573c4f0 to a1abd14 Compare April 18, 2023 12:35
@bholmesdev
Copy link
Contributor Author

!preview data-collections

@github-actions
Copy link
Contributor

 > [email protected] release /home/runner/work/astro/astro > pnpm run build && changeset publish "--tag" "next--data-collections" > [email protected] build /home/runner/work/astro/astro > turbo run build --output-logs=new-only --no-deps --filter=astro --filter=create-astro --filter="@astrojs/*" --filter="@benchmark/*" �[2m• Packages in scope: @astrojs/alpinejs, @astrojs/cloudflare, @astrojs/deno, @astrojs/image, @astrojs/lit, @astrojs/markdoc, @astrojs/markdown-component, @astrojs/markdown-remark, @astrojs/mdx, @astrojs/netlify, @astrojs/node, @astrojs/partytown, @astrojs/preact, @astrojs/prefetch, @astrojs/prism, @astrojs/react, @astrojs/rss, @astrojs/sitemap, @astrojs/solid-js, @astrojs/svelte, @astrojs/tailwind, @astrojs/telemetry, @astrojs/turbolinks, @astrojs/vercel, @astrojs/vue, @astrojs/webapi, @benchmark/timer, astro, create-astro�[0m �[2m• Running�[0m �[2m�[1mbuild�[0m�[0m �[2min 29 packages�[0m �[2m• Remote computation caching enabled (experimental)�[0m �[35m@astrojs/webapi:build: �[0mcache hit, suppressing output �[2maccc674105d3b8ae�[0m �[34mcreate-astro:build: �[0mcache hit, suppressing output �[2m82cb09026d0a05c0�[0m �[33m@astrojs/telemetry:build: �[0mcache hit, suppressing output �[2mc96833b23f5c06a4�[0m �[36m@astrojs/prism:build: �[0mcache hit, suppressing output �[2m94cbdb346a0c129c�[0m �[35m@astrojs/markdown-remark:build: �[0mcache hit, suppressing output �[2m8601dd2ed819bd0d�[0m �[32mastro:build: �[0mcache miss, executing �[2ma1c737393e74ff50�[0m �[32mastro:build: �[0m �[32mastro:build: �[0m> [email protected] build /home/runner/work/astro/astro/packages/astro �[32mastro:build: �[0m> pnpm run prebuild && astro-scripts build "src/**/*.{ts,js}" && tsc && pnpm run postbuild �[32mastro:build: �[0m �[32mastro:build: �[0m �[32mastro:build: �[0m> [email protected] prebuild /home/runner/work/astro/astro/packages/astro �[32mastro:build: �[0m> astro-scripts prebuild --to-string "src/runtime/server/astro-island.ts" "src/runtime/client/{idle,load,media,only,visible}.ts" �[32mastro:build: �[0m �[32mastro:build: �[0m �[32mastro:build: �[0m> [email protected] postbuild /home/runner/work/astro/astro/packages/astro �[32mastro:build: �[0m> astro-scripts copy "src/**/*.astro" && astro-scripts copy "src/**/*.wasm" �[32mastro:build: �[0m �[36m@astrojs/cloudflare:build: �[0mcache miss, executing �[2m11bc1a017dcc35a6�[0m �[35m@astrojs/markdoc:build: �[0mcache miss, executing �[2mbb209a9dad6aec7b�[0m �[32m@astrojs/sitemap:build: �[0mcache miss, executing �[2m2ae879d733aa3831�[0m �[34m@astrojs/mdx:build: �[0mcache miss, executing �[2mabdb71dd1350d842�[0m �[34m@astrojs/alpinejs:build: �[0mcache miss, executing �[2mcf24c3b5beacc6b6�[0m �[32m@astrojs/vue:build: �[0mcache miss, executing �[2mb42c3eeb9e139f6e�[0m �[33m@astrojs/react:build: �[0mcache miss, executing �[2me915a796d6f3d487�[0m �[36m@astrojs/rss:build: �[0mcache miss, executing �[2m6237f85e0fab48fd�[0m �[35m@astrojs/lit:build: �[0mcache miss, executing �[2meb69334330667285�[0m �[33m@astrojs/preact:build: �[0mcache miss, executing �[2m07e957567b7d3ff7�[0m �[36m@astrojs/cloudflare:build: �[0m �[36m@astrojs/cloudflare:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/cloudflare �[36m@astrojs/cloudflare:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[36m@astrojs/cloudflare:build: �[0m �[35m@astrojs/markdoc:build: �[0m �[35m@astrojs/markdoc:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/markdoc �[35m@astrojs/markdoc:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[35m@astrojs/markdoc:build: �[0m �[32m@astrojs/sitemap:build: �[0m �[32m@astrojs/sitemap:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/sitemap �[32m@astrojs/sitemap:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[32m@astrojs/sitemap:build: �[0m �[33m@astrojs/react:build: �[0m �[33m@astrojs/react:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/react �[33m@astrojs/react:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[33m@astrojs/react:build: �[0m �[32m@astrojs/vue:build: �[0m �[32m@astrojs/vue:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/vue �[32m@astrojs/vue:build: �[0m> astro-scripts build "src/index.ts" && astro-scripts build "src/editor.cts" --force-cjs --no-clean-dist && tsc �[32m@astrojs/vue:build: �[0m �[34m@astrojs/mdx:build: �[0m �[34m@astrojs/mdx:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/mdx �[34m@astrojs/mdx:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[34m@astrojs/mdx:build: �[0m �[34m@astrojs/alpinejs:build: �[0m �[34m@astrojs/alpinejs:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/alpinejs �[34m@astrojs/alpinejs:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[34m@astrojs/alpinejs:build: �[0m �[35m@astrojs/lit:build: �[0m �[35m@astrojs/lit:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/lit �[35m@astrojs/lit:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[35m@astrojs/lit:build: �[0m �[36m@astrojs/rss:build: �[0m �[36m@astrojs/rss:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/astro-rss �[36m@astrojs/rss:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[36m@astrojs/rss:build: �[0m �[33m@astrojs/preact:build: �[0m �[33m@astrojs/preact:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/preact �[33m@astrojs/preact:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[33m@astrojs/preact:build: �[0m �[34m@astrojs/solid-js:build: �[0mcache miss, executing �[2mc750e47cca033c8c�[0m �[36m@astrojs/vercel:build: �[0mcache miss, executing �[2m16e180c72277213d�[0m �[35m@astrojs/partytown:build: �[0mcache miss, executing �[2mc67514281aea9dda�[0m �[32m@astrojs/node:build: �[0mcache miss, executing �[2m4ec0ba2cf4b517bc�[0m �[33m@benchmark/timer:build: �[0mcache miss, executing �[2m1ddc09b55c9faa75�[0m �[34m@astrojs/image:build: �[0mcache miss, executing �[2m9d4a8288055b9c1b�[0m �[34m@astrojs/solid-js:build: �[0m �[34m@astrojs/solid-js:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/solid �[34m@astrojs/solid-js:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[34m@astrojs/solid-js:build: �[0m �[36m@astrojs/turbolinks:build: �[0mcache miss, executing �[2m44feee2006cb31af�[0m �[36m@astrojs/vercel:build: �[0m �[36m@astrojs/vercel:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/vercel �[36m@astrojs/vercel:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[36m@astrojs/vercel:build: �[0m �[35m@astrojs/tailwind:build: �[0mcache miss, executing �[2mb3f3e0a3d3e02065�[0m �[35m@astrojs/partytown:build: �[0m �[35m@astrojs/partytown:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/partytown �[35m@astrojs/partytown:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[35m@astrojs/partytown:build: �[0m �[32m@astrojs/svelte:build: �[0mcache miss, executing �[2mc39670f37d8a82ac�[0m �[32m@astrojs/node:build: �[0m �[32m@astrojs/node:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/node �[32m@astrojs/node:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[32m@astrojs/node:build: �[0m �[33m@astrojs/deno:build: �[0mcache miss, executing �[2m0940688d6f772734�[0m �[33m@benchmark/timer:build: �[0m �[33m@benchmark/timer:build: �[0m> @benchmark/[email protected] build /home/runner/work/astro/astro/benchmark/packages/timer �[33m@benchmark/timer:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[33m@benchmark/timer:build: �[0m �[34m@astrojs/image:build: �[0m �[34m@astrojs/image:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/image �[34m@astrojs/image:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[34m@astrojs/image:build: �[0m �[36m@astrojs/turbolinks:build: �[0m �[36m@astrojs/turbolinks:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/turbolinks �[36m@astrojs/turbolinks:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[36m@astrojs/turbolinks:build: �[0m �[35m@astrojs/tailwind:build: �[0m �[35m@astrojs/tailwind:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/tailwind �[35m@astrojs/tailwind:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[35m@astrojs/tailwind:build: �[0m �[32m@astrojs/svelte:build: �[0m �[32m@astrojs/svelte:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/svelte �[32m@astrojs/svelte:build: �[0m> astro-scripts build "src/index.ts" && astro-scripts build "src/editor.cts" --force-cjs --no-clean-dist && tsc �[32m@astrojs/svelte:build: �[0m �[33m@astrojs/deno:build: �[0m �[33m@astrojs/deno:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/deno �[33m@astrojs/deno:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[33m@astrojs/deno:build: �[0m �[34m@astrojs/prefetch:build: �[0mcache miss, executing �[2m754e8e3c39b3d2ac�[0m �[36m@astrojs/netlify:build: �[0mcache miss, executing �[2m7c8395f312f09f31�[0m �[34m@astrojs/prefetch:build: �[0m �[34m@astrojs/prefetch:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/prefetch �[34m@astrojs/prefetch:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[34m@astrojs/prefetch:build: �[0m �[36m@astrojs/netlify:build: �[0m �[36m@astrojs/netlify:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/netlify �[36m@astrojs/netlify:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[36m@astrojs/netlify:build: �[0m Tasks: 28 successful, 28 total Cached: 5 cached, 28 total Time: 1m6.865s Package �[36m"@example/minimal"�[39m must depend on the current version of �[36m"astro"�[39m: �[32m"0.0.0-data-collections-20230418125011"�[39m vs �[31m"^2.3.0"�[39m Package �[36m"@astrojs/markdown-remark"�[39m must depend on the current version of �[36m"astro"�[39m: �[32m"0.0.0-data-collections-20230418125011"�[39m vs �[31m"^2.3.0"�[39m 🦋 �[33mwarn�[39m �[31m===============================IMPORTANT!===============================�[39m 🦋 �[33mwarn�[39m Packages will be released under the next--data-collections tag 🦋 �[33mwarn�[39m �[31m----------------------------------------------------------------------�[39m 🦋 �[36minfo�[39m npm info astro 🦋 �[36minfo�[39m npm info @astrojs/prism 🦋 �[36minfo�[39m npm info @astrojs/rss 🦋 �[36minfo�[39m npm info create-astro 🦋 �[36minfo�[39m npm info @astrojs/alpinejs 🦋 �[36minfo�[39m npm info @astrojs/cloudflare 🦋 �[36minfo�[39m npm info @astrojs/deno 🦋 �[36minfo�[39m npm info @astrojs/image 🦋 �[36minfo�[39m npm info @astrojs/lit 🦋 �[36minfo�[39m npm info @astrojs/markdoc 🦋 �[36minfo�[39m npm info @astrojs/mdx 🦋 �[36minfo�[39m npm info @astrojs/netlify 🦋 �[36minfo�[39m npm info @astrojs/node 🦋 �[36minfo�[39m npm info @astrojs/partytown 🦋 �[36minfo�[39m npm info @astrojs/preact 🦋 �[36minfo�[39m npm info @astrojs/prefetch 🦋 �[36minfo�[39m npm info @astrojs/react 🦋 �[36minfo�[39m npm info @astrojs/sitemap 🦋 �[36minfo�[39m npm info @astrojs/solid-js 🦋 �[36minfo�[39m npm info @astrojs/svelte 🦋 �[36minfo�[39m npm info @astrojs/tailwind 🦋 �[36minfo�[39m npm info @astrojs/turbolinks 🦋 �[36minfo�[39m npm info @astrojs/vercel 🦋 �[36minfo�[39m npm info @astrojs/vue 🦋 �[36minfo�[39m npm info @astrojs/markdown-component 🦋 �[36minfo�[39m npm info @astrojs/markdown-remark 🦋 �[36minfo�[39m npm info @astrojs/telemetry 🦋 �[36minfo�[39m npm info @astrojs/webapi 🦋 �[36minfo�[39m astro is being published because our local version (0.0.0-data-collections-20230418125011) has not been published on npm 🦋 �[33mwarn�[39m @astrojs/prism is not being published because version 2.1.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/rss is not being published because version 2.3.2 is already published on npm 🦋 �[33mwarn�[39m create-astro is not being published because version 3.1.3 is already published on npm 🦋 �[33mwarn�[39m @astrojs/alpinejs is not being published because version 0.2.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/cloudflare is not being published because version 6.2.2 is already published on npm 🦋 �[33mwarn�[39m @astrojs/deno is not being published because version 4.1.0 is already published on npm 🦋 �[33mwarn�[39m @astrojs/image is not being published because version 0.16.6 is already published on npm 🦋 �[33mwarn�[39m @astrojs/lit is not being published because version 2.0.1 is already published on npm 🦋 �[36minfo�[39m @astrojs/markdoc is being published because our local version (0.0.0-data-collections-20230418125011) has not been published on npm 🦋 �[33mwarn�[39m @astrojs/mdx is not being published because version 0.19.0 is already published on npm 🦋 �[33mwarn�[39m @astrojs/netlify is not being published because version 2.2.2 is already published on npm 🦋 �[33mwarn�[39m @astrojs/node is not being published because version 5.1.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/partytown is not being published because version 1.2.0 is already published on npm 🦋 �[33mwarn�[39m @astrojs/preact is not being published because version 2.1.0 is already published on npm 🦋 �[33mwarn�[39m @astrojs/prefetch is not being published because version 0.2.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/react is not being published because version 2.1.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/sitemap is not being published because version 1.2.2 is already published on npm 🦋 �[33mwarn�[39m @astrojs/solid-js is not being published because version 2.1.0 is already published on npm 🦋 �[33mwarn�[39m @astrojs/svelte is not being published because version 2.1.0 is already published on npm 🦋 �[33mwarn�[39m @astrojs/tailwind is not being published because version 3.1.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/turbolinks is not being published because version 0.2.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/vercel is not being published because version 3.2.4 is already published on npm 🦋 �[33mwarn�[39m @astrojs/vue is not being published because version 2.1.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/markdown-component is not being published because version 1.0.3 is already published on npm 🦋 �[33mwarn�[39m @astrojs/markdown-remark is not being published because version 2.1.4 is already published on npm 🦋 �[33mwarn�[39m @astrojs/telemetry is not being published because version 2.1.0 is already published on npm 🦋 �[33mwarn�[39m @astrojs/webapi is not being published because version 2.1.0 is already published on npm 🦋 �[36minfo�[39m Publishing �[36m"astro"�[39m at �[32m"0.0.0-data-collections-20230418125011"�[39m 🦋 �[36minfo�[39m Publishing �[36m"@astrojs/markdoc"�[39m at �[32m"0.0.0-data-collections-20230418125011"�[39m 🦋 �[32msuccess�[39m packages published successfully: 🦋 [email protected] 🦋 @astrojs/[email protected] 🦋 Creating git tags... 🦋 New tag: [email protected] 🦋 New tag: @astrojs/[email protected]

@louiss0
Copy link
Contributor

louiss0 commented Apr 20, 2023

I'm concerned about the fact that each file format might become a new folder name is this the only folder for data that is not markdown? What about other files?

@louiss0
Copy link
Contributor

louiss0 commented Apr 20, 2023

!preview data-collections

I know you guys said you were going to support content collections. But I wonder what other formats are you going to support? I wonder whether or not other folders would be taken from people. I think from now on it's better to stop taking top level folders from people and instead just take folders in content collections.

I'm saying this because with this PR four folders are taken from people. One of them being assets. That folder was used for more than images by some people, especially React Devs.

@bholmesdev
Copy link
Contributor Author

@louiss0 To clarify, we do not require or own an assets/ directory! This is a convention we like to demo to show alias support, but it's not required to use image optimization.

As for the proliferation of folders, that is a good concern to keep in mind. As we see it, there won't be further "collection" types beyond content and data, so I'd expect content/ and data/ to be the only two reserved directories (other than pages/ of course). If we do find a reason for more content types, I agree combining into a single dir or using config-based collections would be best!

@louiss0
Copy link
Contributor

louiss0 commented Apr 25, 2023

@louiss0 To clarify, we do not require or own an assets/ directory! This is a convention we like to demo to show alias support, but it's not required to use image optimization.

As for the proliferation of folders, that is a good concern to keep in mind. As we see it, there won't be further "collection" types beyond content and data, so I'd expect content/ and data/ to be the only two reserved directories (other than pages/ of course). If we do find a reason for more content types, I agree combining into a single dir or using config-based collections would be best!
Ok then I wonder Is there anyone working on Markdoc? I have found some issues with it and no one has responded so far.

@louiss0
Copy link
Contributor

louiss0 commented Apr 25, 2023

Oh, I'm pro moving the config.ts out of the content file. Maybe it will work like a regular config file instead. Is there any other options that will be added to define Collection in the future?

@louiss0
Copy link
Contributor

louiss0 commented Apr 25, 2023

I'm also concerned about Markdoc. They are written here.

@bholmesdev bholmesdev force-pushed the feat/data-collections branch from fadee16 to 9cc4539 Compare April 28, 2023 17:06
@bholmesdev
Copy link
Contributor Author

@louiss0 I'm also the active maintainer of @astrojs/markdoc 🙃 I'm trying not to divide my attention too much, so I've left Markdoc proposals in my unread until next week. Happy to take a look at your roadmap discussion!

@louiss0
Copy link
Contributor

louiss0 commented Apr 28, 2023

@louiss0 I'm also the active maintainer of @astrojs/markdoc 🙃 I'm trying not to divide my attention too much, so I've left Markdoc proposals in my unread until next week. Happy to take a look at your roadmap discussion!

That thing has problems I tried to file an issue but that was shut down by Matt. I think you are the one to solve the problems from that issue. He told me to spilt up each of the problems into different issues But I think they are too small. Here's the link to the issues #6829 (comment).

@louiss0
Copy link
Contributor

louiss0 commented Apr 28, 2023

@louiss0 I'm also the active maintainer of @astrojs/markdoc 🙃 I'm trying not to divide my attention too much, so I've left Markdoc proposals in my unread until next week. Happy to take a look at your roadmap discussion!

Keep going bud. I'm in no rush to use Markdoc. I care more about Assets right now. I just decided to put my thoughts out there. I don't know how much you are going to extend it or if Remark is going to be involved but I just hope we don't lose the DX of using mdx too much.

@bholmesdev bholmesdev force-pushed the feat/data-collections branch from 65aa7e1 to b2b98b6 Compare April 28, 2023 21:46
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These error messages are super-nicely done, @bholmesdev! I would be honoured to make a mistake with my collections! Just a couple of thoughts for you to consider below!

packages/astro/src/core/errors/errors-data.ts Outdated Show resolved Hide resolved
packages/astro/src/core/errors/errors-data.ts Outdated Show resolved Hide resolved
bholmesdev and others added 2 commits May 16, 2023 15:42
Co-authored-by: Sarah Rainsberger <[email protected]>
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried my best to review this huge PR 😄 Code looks good to me. Have a couple extra suggestions below

packages/astro/src/core/sync/index.ts Show resolved Hide resolved
.changeset/early-eyes-bow.md Outdated Show resolved Hide resolved
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some TODO in the code, but I don't understand when you aim to address them. This PR? Next PR? Maybe a mention in the description of the PR could shed some light;

There are a few places where we need to catch errors:

  • I/O operations, it's minor but you never the permissions of the file system
  • JSON.parse, very important. If the contents of a file are not a valid JSON object, the function will throw a runtime error.

.changeset/early-eyes-bow.md Outdated Show resolved Hide resolved
packages/astro/src/content/runtime.ts Outdated Show resolved Hide resolved
packages/astro/src/content/runtime.ts Outdated Show resolved Hide resolved
packages/astro/src/content/utils.ts Outdated Show resolved Hide resolved
packages/astro/src/content/vite-plugin-content-imports.ts Outdated Show resolved Hide resolved
packages/astro/src/content/vite-plugin-content-imports.ts Outdated Show resolved Hide resolved
if (entryType !== 'content' && entryType !== 'data') return;

const collection = getEntryCollectionName({ contentDir, entry: pathToFileURL(filePath) });
if (!collection) throw UnexpectedLookupMapError;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it! ❤️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Learn from the best ❤️

packages/astro/src/core/config/settings.ts Outdated Show resolved Hide resolved
@bholmesdev bholmesdev merged commit c6d7ebe into main May 17, 2023
@bholmesdev bholmesdev deleted the feat/data-collections branch May 17, 2023 15:36
@astrobot-houston astrobot-houston mentioned this pull request May 17, 2023
ArmandPhilippot added a commit to ArmandPhilippot/astro-docs that referenced this pull request Jul 29, 2024
* See withastro/astro#7607 for the most recent
exported types
* See withastro/astro#6850 for `reference()`
* See `packages/astro/types/content.d.ts` for `schema` type (might
need a refactor)
* `getDataEntryById` is missing but since `getEntryBySlug` is
announced as deprecated I don't know if we should add it (so
no change here)
ArmandPhilippot added a commit to ArmandPhilippot/astro-docs that referenced this pull request Jul 29, 2024
* See withastro/astro#7607 for the most recent
exported types
* See withastro/astro#6850 for `reference()`
* See `packages/astro/types/content.d.ts` for `schema` type (might
need a refactor)
* `getDataEntryById` is missing but since `getEntryBySlug` is
announced as deprecated I don't know if we should add it (so
no change here)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants