Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sombriks/koa-webc
koa middleware to render WebC views
https://github.com/sombriks/koa-webc
koa webc
Last synced: 3 days ago
JSON representation
koa middleware to render WebC views
- Host: GitHub
- URL: https://github.com/sombriks/koa-webc
- Owner: sombriks
- Created: 2023-03-18T20:56:38.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-02T12:31:52.000Z (over 1 year ago)
- Last Synced: 2024-12-06T08:04:31.056Z (2 months ago)
- Topics: koa, webc
- Language: JavaScript
- Homepage:
- Size: 228 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# The KoaWebC plugin
[![build status](https://github.com/sombriks/koa-webc/actions/workflows/node.js.yml/badge.svg)](https://github.com/sombriks/koa-webc)
[![npm version](https://img.shields.io/npm/v/koa-webc?style=plastic)](https://www.npmjs.com/package/koa-webc)This plugin enables [Koa](https://koajs.com/) to serve
[WebC](https://github.com/11ty/webc)
[pages](https://11ty.rocks/posts/introduction-webc/).## Installing
```bash
npm i koa-webc
```## Basic usage
```js
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
```js
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](https://github.com/sombriks/koa-webc-examples)
## Roadmap
- [X] initial support
- [X] npm package publishing
- [X] dedicated example project with snippets
- [X] check interaction with other middlewares
- [X] [documentation](index.d.ts) once api gets stable
- [ ] performance/benchmark tests
- [ ] CI/CD to automatically publish on npm