7}
8
9export function Layout({ title, children }: LayoutProps) {
10 return (
11 <html lang="en">
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();
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);
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 (local + RSS)
6export async function getAllBlogPosts(): Promise<BlogPost[]> {
7 return (await Promise.all([
8 getNewPosts(),
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
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">
80];
81
82function FoodMenuItem({ item, onAddToCart }) {
83 return (
84 <div className="menu-item">
104}
105
106function CheckoutForm({ cart, totalPrice, onSubmit }) {
107 const [name, setName] = useState("");
108 const [phone, setPhone] = useState("");
161}
162
163function App() {
164 const [cart, setCart] = useState([]);
165 const [orderPlaced, setOrderPlaced] = useState(false);
257}
258
259function client() {
260 createRoot(document.getElementById("root")).render(<App />);
261}
262if (typeof document !== "undefined") { client(); }
263
264export default async function server(request: Request): Promise<Response> {
265 if (request.method === "POST" && new URL(request.url).pathname === "/submit-order") {
266 try {
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`}>
9
10// Process markdown content
11export async function processMarkdown(content: string): Promise<string> {
12 const result = await unified()
13 .use(remarkParse)
A helper function to build a file's email
Simple functional CSS library for Val Town
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": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.