Skip to content

sombriks/koa-webc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The KoaWebC plugin

build status npm version

This plugin enables Koa to serve WebC pages.

Installing

npm i koa-webc

Basic usage

import Koa from "koa"
import { KoaWebC } from "koa-webc"

const app = new Koa()
app.use(KoaWebC())

app.use(async ctx => ctx.render("hello-world.webc"))

app.listen(3000)
console.log("http://localhost:3000")

Using with other middlewares

const app = new Koa()
const router = new Router()

router.get("/the-extras", async ctx => {
  // override data options
  await ctx.render("the-extras.webc", {data: {bar: 'baz', xpto: "xpto"}})
})

// middleware registration order is important
app
  .use(KoaWebC({
    bundle: true,
    viewPath: path.join(process.cwd(), "test", "fixtures"),
    data: {
      foo: "foo",
      bar: "bar"
    }
  }))
  .use(router.routes())
  .use(router.allowedMethods())
  .listen(3000)
console.log("http://localhost:3000")

See more examples

Roadmap

  • initial support
  • npm package publishing
  • dedicated example project with snippets
  • check interaction with other middlewares
  • documentation once api gets stable
  • performance/benchmark tests
  • CI/CD to automatically publish on npm

About

koa middleware to render WebC views

Topics

Resources

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published