| 135 | } |
| 136 | |
| 137 | async function loadPostComponents(slug: string): Promise<Record<string, React.ComponentType>> { |
| 138 | if (postComponentsRegistry[slug]) { |
| 139 | return postComponentsRegistry[slug] |
| 140 | } |
| 141 | |
| 142 | const loader = BLOG_COMPONENT_LOADERS[slug] |
| 143 | if (!loader) { |
| 144 | postComponentsRegistry[slug] = {} |
| 145 | return {} |
| 146 | } |
| 147 | |
| 148 | try { |
| 149 | const postComponents = await loader() |
| 150 | postComponentsRegistry[slug] = postComponents |
| 151 | return postComponents |
| 152 | } catch { |
| 153 | postComponentsRegistry[slug] = {} |
| 154 | return {} |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | export async function getPostBySlug(slug: string): Promise<BlogPost> { |
| 159 | const meta = await scanFrontmatters() |