├── .gitignore ├── _config.ts ├── .vscode ├── settings.json └── launch.json ├── index.njk ├── README.md ├── .github └── workflows │ └── ci.yml └── server └── main.ts /.gitignore: -------------------------------------------------------------------------------- 1 | _site -------------------------------------------------------------------------------- /_config.ts: -------------------------------------------------------------------------------- 1 | import lume from "https:/deno.land/x/lume@v1.5.1/mod.ts"; 2 | 3 | const site = lume(); 4 | site.copy("assets", "."); 5 | 6 | export default site; 7 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "deno.enable": true, 3 | "deno.lint": true, 4 | "deno.unstable": true, 5 | "deno.suggest.imports.hosts": { 6 | "https://deno.land": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /index.njk: -------------------------------------------------------------------------------- 1 | --- 2 | title: Welcome to my page 3 | --- 4 | 5 | 6 |
7 |This is an example of a static site generated by Lume on Deno Deploy.
12 |The /api/time endpoint dynamically returns the current time.
13 |You can find the source code for this site on GitHub.
14 | 15 | 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # deploy_lume_example 2 | 3 | This is an example of a static site generated by the [Lume][lume] static site 4 | generator being deployed to Deno Deploy via GitHub Actions. 5 | 6 | To learn more about static files on Deno Deploy, view this blog post: 7 | https://deno.com/blog/deploy-static-files 8 | 9 | ## Development 10 | 11 | First, install [Lume][lume]. 12 | 13 | ```shell 14 | deno run -A https://deno.land/x/lume/install.ts 15 | ``` 16 | 17 | Then build the site: 18 | 19 | ```shell 20 | lume 21 | ``` 22 | 23 | Then start the server: 24 | 25 | ```shell 26 | deno run -A server/main.ts 27 | ``` 28 | 29 | [lume]: https://lumeland.github.io 30 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | deploy: 13 | name: deploy 14 | runs-on: ubuntu-latest 15 | permissions: 16 | id-token: write 17 | contents: read 18 | 19 | steps: 20 | - name: Clone repository 21 | uses: actions/checkout@v3 22 | 23 | - name: Install Deno 24 | uses: denoland/setup-deno@main 25 | with: 26 | deno-version: v1.x 27 | 28 | - name: Build site 29 | run: deno run -A https://deno.land/x/lume@v1.5.1/ci.ts 30 | 31 | - name: Deploy to Deno Deploy 32 | uses: denoland/deployctl@v1 33 | with: 34 | project: lume-example 35 | entrypoint: server/main.ts 36 | -------------------------------------------------------------------------------- /server/main.ts: -------------------------------------------------------------------------------- 1 | import { Application, Router } from "https://deno.land/x/oak@v10.2.0/mod.ts"; 2 | 3 | const app = new Application(); 4 | 5 | // First we try to serve static files from the _site folder. If that fails, we 6 | // fall through to the router below. 7 | app.use(async (ctx, next) => { 8 | try { 9 | await ctx.send({ 10 | root: `${Deno.cwd()}/_site`, 11 | index: "index.html", 12 | }); 13 | } catch { 14 | next(); 15 | } 16 | }); 17 | 18 | const router = new Router(); 19 | 20 | // The /api/time endpoint returns the current time in ISO format. 21 | router.get("/api/time", (ctx) => { 22 | ctx.response.body = { time: new Date().toISOString() }; 23 | }); 24 | 25 | // After creating the router, we can add it to the app. 26 | app.use(router.routes()); 27 | app.use(router.allowedMethods()); 28 | 29 | await app.listen({ port: 8000 }); 30 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "request": "launch", 6 | "type": "pwa-node", 7 | "program": "https:/deno.land/x/lume@v1.5.1/cli.ts", 8 | "cwd": "${workspaceFolder}", 9 | "runtimeExecutable": "deno", 10 | "runtimeArgs": [ 11 | "run", 12 | "--unstable", 13 | "--import-map=.vscode/lume_import_map.json", 14 | "--inspect", 15 | "--allow-all" 16 | ], 17 | "attachSimplePort": 9229, 18 | "name": "Lume build" 19 | }, 20 | { 21 | "request": "launch", 22 | "type": "pwa-node", 23 | "program": "https:/deno.land/x/lume@v1.5.1/cli.ts", 24 | "cwd": "${workspaceFolder}", 25 | "runtimeExecutable": "deno", 26 | "runtimeArgs": [ 27 | "run", 28 | "--unstable", 29 | "--import-map=.vscode/lume_import_map.json", 30 | "--inspect", 31 | "--allow-all" 32 | ], 33 | "attachSimplePort": 9229, 34 | "name": "Lume serve", 35 | "args": [ 36 | "--serve" 37 | ] 38 | } 39 | ] 40 | } --------------------------------------------------------------------------------