Skip to content

esroyo/hono-webc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

155e3ae Â· Sep 7, 2024

History

40 Commits
Jun 7, 2024
Sep 7, 2024
Jun 17, 2024
Jun 6, 2024
Jun 7, 2024
Jun 6, 2024
Sep 7, 2024
Sep 6, 2024
Jun 17, 2024
Sep 7, 2024
Sep 7, 2024
Sep 7, 2024
Jun 7, 2024
Jun 17, 2024
Jun 17, 2024
Jun 6, 2024

Repository files navigation

WebC middleware for Hono

JSR JSR Score codecov

Enables usage of 🔧 WebC components/pages in 🔥 Hono.

Basic usage

import { Hono } from 'jsr:@hono/hono';
import { createWebcMiddleware } from 'jsr:@esroyo/hono-webc';

const app = new Hono();
app.use(createWebcMiddleware({
    data: { title: 'My Website' },
    input: `
      <!doctype html>
      <html>
        <head><title @text="title"></title></head>
        <body><slot></slot></body>
      </html>
    `,
    defineComponents: {
        'hello-world': '<h1><slot>No slotted content</slot></h1>',
    },
}));

app.get('/', async (ctx) => {
  return ctx.render('<hello-world>Hello, WebC!</hello-world>');
});

Deno.serve(app.fetch, { port: 8000 });

/** output:

<!doctype html>
<html>
  <head><title>My Website</title></head>
  <body><h1>Hello, WebC!</h1></body>
</html>

*/

About

Enables usage of WebC in Hono

Resources

License

Stars

Watchers

Forks

Packages

No packages published