62```ts
63// Example of how we fetch blog posts
64async function getAllBlogPosts() {
65 // Get local posts from markdown files
66 const localPosts = await getLocalBlogPosts();
9
10// Process markdown content
11export async function processMarkdown(content: string): Promise<string> {
12 const result = await unified()
13 .use(remarkParse)
5const OLD_BLOG_URL = "https://val-town-blog.pages.dev/";
6
7export async function proxyHonoRequest(c: any) {
8 const url = new URL(c.req.url);
9
7}
8
9export function Layout({ title, children }: LayoutProps) {
10 return (
11 <html lang="en">
4import { Layout } from "./Layout.tsx";
5
6function formatDate(dateString: string): string {
7 try {
8 const date = new Date(dateString);
16}
17
18export function HomePage({ posts }: { posts: BlogPost[] }) {
19 return (
20 <Layout title="Val Town Blog">
4
5// Get all blog posts (local + RSS)
6export async function getAllBlogPosts(): Promise<BlogPost[]> {
7 return (await Promise.all([
8 getNewPosts(),
4const OLD_BLOG_RSS = "https://val-town-blog.pages.dev/rss.xml";
5// Get blog posts from RSS feed
6export async function getOldPosts(): Promise<BlogPost[]> {
7 const parser = new RssParser();
8 const feed = await parser.parseURL(OLD_BLOG_RSS);
4
5// Get all blog posts from the file system
6export async function getNewPosts(): Promise<BlogPost[]> {
7 const files = await listFiles(import.meta.url);
8 const blogPostFiles = files.filter(
38
39// Get a single blog post by slug
40export async function getBlogPostBySlug(slug: string): Promise<BlogPost | null> {
41 const content = await readFile(`/posts/${slug}.md`, import.meta.url);
42 const { data, content: markdownContent } = matter(content);
21
22```typescript
23function hello() {
24 console.log("Hello, Val Town!");
25}
9}
10
11function formatDate(dateString: string): string {
12 try {
13 const date = new Date(dateString);
22}
23
24export function BlogPostComponent({ post, content }: BlogPostProps) {
25 return (
26 <Layout title={`${post.title} - Val Town Blog`}>
A helper function to build a file's email
Simple functional CSS library for Val Town
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",