this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 31 lines 1.6 kB view raw
1import { createServerFn } from "@tanstack/react-start"; 2import { staticFunctionMiddleware } from "@tanstack/start-static-server-functions"; 3import { renderServerComponent } from "@tanstack/react-start/rsc"; 4 5import { ArticleSlugSchema, type ArticleSlug } from "./schemas"; 6import { ArticleShell } from "./__article-shell.server"; 7 8const articlesContent: Record<ArticleSlug, () => Promise<string>> = { 9 basic: () => import("./__content/basic.md?raw").then((m) => m.default), 10 preloading: () => import("./__content/preloading.md?raw").then((m) => m.default), 11 "intent-preloading": () => import("./__content/intent-preloading.md?raw").then((m) => m.default), 12 pagination: () => import("./__content/pagination.md?raw").then((m) => m.default), 13 filters: () => import("./__content/filters.md?raw").then((m) => m.default), 14 "debounced-preload-filters": () => 15 import("./__content/debounced-preload-filters.md?raw").then((m) => m.default), 16 "live-query": () => import("./__content/live-query.md?raw").then((m) => m.default), 17 "live-query-filters": () => 18 import("./__content/live-query-filters.md?raw").then((m) => m.default), 19}; 20 21export const getServerArticleStream = createServerFn({ method: "GET" }) 22 .middleware([staticFunctionMiddleware]) 23 .inputValidator(ArticleSlugSchema) 24 .handler(async ({ data: slug }) => { 25 const getArticleContent = articlesContent[slug]; 26 const markdown = await getArticleContent(); 27 28 const Renderable = await renderServerComponent(<ArticleShell markdown={markdown} />); 29 30 return { Renderable }; 31 });