From 57620a2404c8152ca8af6739d268d62661158c66 Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Tue, 30 Jul 2024 20:15:10 -0400 Subject: [PATCH] Some reason the serveStatic isn't serving static. --- src/assets/main.css | 2 ++ src/config.ts | 2 +- src/index.tsx | 4 ++++ src/templates/Page.tsx | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 src/assets/main.css diff --git a/src/assets/main.css b/src/assets/main.css new file mode 100644 index 0000000..fdcf84e --- /dev/null +++ b/src/assets/main.css @@ -0,0 +1,2 @@ +/* Do something */ + diff --git a/src/config.ts b/src/config.ts index aa64bb2..d8809fc 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,4 +1,4 @@ export const POST_PATH: string = __dirname + '/../posts'; -export const STATIC_PATH: string = __dirname + '/../static'; +export const STATIC_PATH: string = __dirname + '/assets'; export const POST_ROUTE_PREFIX: string = '/posts' export const SQLITE_DATABASE_FILE: string = __dirname + '/../db/blog.sqlite'; diff --git a/src/index.tsx b/src/index.tsx index 72883b3..4c7528f 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,11 +1,13 @@ import { Hono } from 'hono'; import { jsxRenderer } from 'hono/jsx-renderer'; +import { serveStatic } from 'hono/bun'; import { Page } from '@blog/templates/Page'; import home from '@blog/handlers/home'; import posts from '@blog/handlers/posts'; import type { SiteMeta } from '@blog/models/SiteMeta'; import { postFileMiddleware } from '@blog/middleware/post-service'; import { logger } from 'hono/logger'; +import { STATIC_PATH } from '@blog/config'; declare module 'hono' { interface ContextRenderer { @@ -27,6 +29,8 @@ app.get( ) ); +app.get('/static/*', serveStatic({ root: "./assets/" })); + console.log(JSON.stringify({ message: "Bootstrapping the routes..." })); app.route('/', home); app.route('/posts', posts); diff --git a/src/templates/Page.tsx b/src/templates/Page.tsx index 2ee969d..7ed6b75 100644 --- a/src/templates/Page.tsx +++ b/src/templates/Page.tsx @@ -13,6 +13,7 @@ export function Page({ children, meta }: { children: any, meta: SiteMeta }) { davesmithhayes.com