You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use collection content fetching API without having to create static content.
Background & Motivation
Currently, content collections have to be directories with static markdown files. I'd like to be able to fetch external dynamic content and turn it into a content collection. That is needed in order to be able to render dynamic navigation for example.
Goals
Render full site navigation tree in a layout
Support dynamic and external content
Example
It is now possible to have some code to fetch generate dynamic content (e.g. src/data.ts). Then create a page with dynamic route (src/pages/posts/[slug].astro) using that code to render itself. It is then also possible to create a navigation tree component (src/components/tree.astro) that would import the same data (from src/data.ts) and render a tree. However, in this solution the component lacks astro knowledge of the resulting page URL which depends on router logic (albeit trivial).
It would be ideal to have API to iterate over the complete astro site pages collection containing all resolved static paths and feed it into the navigation tree component.
I've seen the sitemap plugin, but it works by generating the file after the whole site has been completely built. Maybe it would be useful to introduce a plugin hook at the stage when all routes are resolved but before pages rendered.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Summary
Use collection content fetching API without having to create static content.
Background & Motivation
Currently, content collections have to be directories with static markdown files. I'd like to be able to fetch external dynamic content and turn it into a content collection. That is needed in order to be able to render dynamic navigation for example.
Goals
Example
It is now possible to have some code to fetch generate dynamic content (e.g.
src/data.ts
). Then create a page with dynamic route (src/pages/posts/[slug].astro
) using that code to render itself. It is then also possible to create a navigation tree component (src/components/tree.astro
) that would import the same data (fromsrc/data.ts
) and render a tree. However, in this solution the component lacks astro knowledge of the resulting page URL which depends on router logic (albeit trivial).It would be ideal to have API to iterate over the complete astro site pages collection containing all resolved static paths and feed it into the navigation tree component.
I've seen the sitemap plugin, but it works by generating the file after the whole site has been completely built. Maybe it would be useful to introduce a plugin hook at the stage when all routes are resolved but before pages rendered.
Beta Was this translation helpful? Give feedback.
All reactions