Home / Function/ fetchPosts() — astro Function Reference

fetchPosts() — astro Function Reference

Architecture documentation for the fetchPosts() function in posts.json.js from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  e7f1fddd_3667_39c9_047f_a0aa733dd547["fetchPosts()"]
  6e84638a_826e_25b4_2cdf_ecca70f40aa6["posts.json.js"]
  e7f1fddd_3667_39c9_047f_a0aa733dd547 -->|defined in| 6e84638a_826e_25b4_2cdf_ecca70f40aa6
  b0cc6a5c_21ec_9070_b9c0_2abc361f8762["GET()"]
  b0cc6a5c_21ec_9070_b9c0_2abc361f8762 -->|calls| e7f1fddd_3667_39c9_047f_a0aa733dd547
  style e7f1fddd_3667_39c9_047f_a0aa733dd547 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/test/fixtures/static-build/src/pages/posts.json.js lines 1–14

async function fetchPosts() {
    const files = import.meta.glob('./posts/**/*.md');
    
    const posts = await Promise.all(
        Object.entries(files).map(([filename, load]) => load().then(({ frontmatter }) => {
            return {
                filename,
                title: frontmatter.title,
            };
        })),
    );

    return posts.sort((a, b) => a.title.localeCompare(b.title));
}

Subdomains

Called By

Frequently Asked Questions

What does fetchPosts() do?
fetchPosts() is a function in the astro codebase, defined in packages/astro/test/fixtures/static-build/src/pages/posts.json.js.
Where is fetchPosts() defined?
fetchPosts() is defined in packages/astro/test/fixtures/static-build/src/pages/posts.json.js at line 1.
What calls fetchPosts()?
fetchPosts() is called by 1 function(s): GET.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free