docs icon indicating copy to clipboard operation
docs copied to clipboard

Observations on beta documentation about the new content loaders

Open Because789 opened this issue 1 year ago • 4 comments

📚 Subject area/topic

Content loaders

📋 Page(s) affected (or suggested, for new content)

Inline loaders Inline loaders

📋 Description of content that is out-of-date or incorrect

I'm making myself familiar with the new content loaders. I'm sure, the docs on them are still a work in progress, here anyway some observations:

  • There is some redundant information (see provided links). Maybe the whole Building a custom loader could be moved to Astro Content Loader API.
  • This sentence gives me shudders An inline loader is an async function that returns an array or object containing entries. Use this for simple loaders, particularly those that are defined inline in the src/content/config.ts file. (Astro Content Loader API.) I guess An inline loader is an async function that returns an array or object containing entries. Use this for simple loaders defined in the src/content/config.ts file. could be enough.

Edit: The loader.ts example in Object loaders has several issues:

  • Semicolon instead of comma line 9, missing comma line 14
  • Cannot find name 'loadFeedData'. line 13
  • Missing z import line 18

🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)

No response

Because789 avatar Oct 20 '24 11:10 Because789

Thank you for pointing out the errors in the Object loaders example! I would welcome a PR to the beta branch to fix these! I am adding the "help wanted" label so that you or anyone in the community is welcome to contribute the updates.

And yes, all of our beta docs are very much a work in progress! :sweat_smile: As more people use this (experimental or stable-but-beta) feature, we see how people are using the feature in practice and what kind of documentation is helpful (and where). As you've identified, a loader can be as simple as an inline function or an involved setup. We specifically chose some redundancy to allow this content to be easily available to those creating inline loaders, who do not necessarily need to be taken to the full reference page (It is an extra page navigation, extra context switch and also contains information they may not need). The current structure allows them to complete their content collections configuration without leaving the current guide.

A PR for the loaders reference example is up for grabs if someone gets to it before I do!

sarah11918 avatar Oct 22 '24 12:10 sarah11918

Hey @sarah11918, thanks for the information on the state of the docs, that all makes a lot of sense.

As for the PR, I would have already committed it, but I have no idea how to fix Cannot find name 'loadFeedData'. Is this supposed to be a custom function? It's only found here in the docs. Or is it a function provided by Astro, which changed its name int the meantime, or something like that?

Because789 avatar Oct 22 '24 13:10 Because789

Hi @Because789, There is no loadFeedData function exported by Astro. As you thought, it is a "custom function". So I think we only miss a line import { loadFeedData } from "../utils"; (or something like that) in the example after the import from astro/loaders. The implementation is user dependent so it is not really possible to show the contents of this file in the documentation.

Hope this clears up your doubts!

ArmandPhilippot avatar Oct 22 '24 21:10 ArmandPhilippot

The PR is done: https://github.com/withastro/docs/pull/9777

Because789 avatar Oct 23 '24 08:10 Because789

PR has been merged, so I'm not sure why this issue didn't close. Thank you again!

sarah11918 avatar Oct 30 '24 15:10 sarah11918