3const TABLE_NAME = "todos_v1";
4
5export async function createTodoTable() {
6 await sqlite.execute(`CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
7 id INTEGER PRIMARY KEY AUTOINCREMENT,
3const TABLE_NAME = "todos_v1";
4
5export async function createTodoTable() {
6 await sqlite.execute(`CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
7 id INTEGER PRIMARY KEY AUTOINCREMENT,
45 - **`rss.ts`**: RSS feed generation
46 - **`favicon.ts`** & **`og-image.ts`**: Asset routes
47- **`/utils/`**: Utility functions for post processing, caching, etc.
48- **`/posts/`**: Markdown files for blog posts
49- **`/styles/`**: CSS styling
8const HLJS_DARK_CSS_URL = "https://cdn.jsdelivr.net/npm/highlight.js@11.8.0/styles/base16/solar-flare.css";
9
10export default function Head({ title, post }: {
11 title: string;
12 post?: BlogPost;
15}
16
17export function Layout({ title, post, children }: LayoutProps) {
18 return (
19 <html lang="en">
2import React from "https://esm.sh/react@18.2.0";
3
4export default function ThemeToggle() {
5 return (
6 <>
15 <script dangerouslySetInnerHTML={{
16 __html: `
17 (function() {
18 // Get saved theme or default to system preference
19 const savedTheme = localStorage.getItem('theme');
25
26 // Update icon
27 function updateIcon(theme) {
28 const icon = document.getElementById('theme-icon');
29 if (icon) {
34 updateIcon(currentTheme);
35
36 // Toggle function
37 function toggleTheme() {
38 const current = document.documentElement.getAttribute('data-theme');
39 const newTheme = current === 'dark' ? 'light' : 'dark';
45
46 // Add click listener when DOM is ready
47 document.addEventListener('DOMContentLoaded', function() {
48 const toggle = document.getElementById('theme-toggle');
49 if (toggle) {
53
54 // Listen for system theme changes
55 window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function(e) {
56 if (!localStorage.getItem('theme')) {
57 const newTheme = e.matches ? 'dark' : 'light';
330 border-radius: 9999px;
331 transition-property: color, background-color;
332 transition-timing-function: ease-in-out;
333 transition-duration: 200ms;
334}
442 justify-content: center;
443 transition-property: color, background-color;
444 transition-timing-function: ease-in-out;
445 transition-duration: 200ms;
446 font-size: 18px;
1export function formatDate(dateString: string): string {
2 try {
3 const date = new Date(dateString);
12}
13
14export function dayOfWeek(dateString: string): string {
15 try {
16 return new Date(dateString).toLocaleDateString("en-US", {
2import { BlueskyIcon, DiscordIcon, GitHubIcon, RSSIcon, TwitterIcon } from "./icons.tsx";
3
4export default function SocialLinks() {
5 return (
6 <div className="social-links">
10
11// Process markdown content
12export async function processMarkdown(content: string): Promise<string> {
13 const result = await unified()
14 .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.