post-loader.ts — astro Source File
Architecture documentation for post-loader.ts, a typescript file in the astro codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 2d34d070_3638_0582_69ab_6b29151c3933["post-loader.ts"] 48f80d01_e646_3924_78f6_a9d836644746["astro:content"] 2d34d070_3638_0582_69ab_6b29151c3933 --> 48f80d01_e646_3924_78f6_a9d836644746 d47373dc_6761_5858_3027_a4a6472dd795["loaders"] 2d34d070_3638_0582_69ab_6b29151c3933 --> d47373dc_6761_5858_3027_a4a6472dd795 style 2d34d070_3638_0582_69ab_6b29151c3933 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { z } from 'astro:content';
import type { Loader } from "astro/loaders"
export interface PostLoaderConfig {
url: string;
}
export function loader(config:PostLoaderConfig): Loader {
return {
name: "post-loader",
load: async ({
store, meta, logger
}) => {
logger.info('Loading posts');
const lastSynced = meta.get('lastSynced');
// Don't sync more than once a minute
if (lastSynced && (Date.now() - Number(lastSynced) < 1000 * 60)) {
logger.info('Skipping sync');
return;
}
const posts = await fetch(config.url)
.then((res) => res.json());
store.clear();
for (const data of posts) {
store.set({id: data.id, data});
}
meta.set('lastSynced', String(Date.now()));
},
schema: async () => {
// Simulate a delay
await new Promise((resolve) => setTimeout(resolve, 1000));
return z.object({
title: z.string(),
body: z.string(),
userId: z.number(),
id: z.number(),
});
}
};
}
Domain
Subdomains
Functions
Types
Dependencies
- astro:content
- loaders
Source
Frequently Asked Questions
What does post-loader.ts do?
post-loader.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RoutingSystem subdomain.
What functions are defined in post-loader.ts?
post-loader.ts defines 1 function(s): loader.
What does post-loader.ts depend on?
post-loader.ts imports 2 module(s): astro:content, loaders.
Where is post-loader.ts in the architecture?
post-loader.ts is located at packages/integrations/cloudflare/test/fixtures/vite-plugin/src/loaders/post-loader.ts (domain: CoreAstro, subdomain: RoutingSystem, directory: packages/integrations/cloudflare/test/fixtures/vite-plugin/src/loaders).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free