pmlag

Poor man's link aggregation
git clone git://git.finwo.net/app/pmlag
Log | Files | Refs | README | LICENSE

commit 590ca42b0103e0743dbab9264e00b40365b018c1
parent f9bc15ba7fbf3d90bd65d687997035bcdf06e41f
Author: Yersa Nordman <yersa@finwo.nl>
Date:   Tue, 14 Mar 2023 22:02:51 +0100

Testing routing after being built in gha

Diffstat:
M.github/workflows/docs-build-and-deploy.yml | 2++
Mdoc/build.js | 25+++++++------------------
Mdoc/package-lock.json | 8+++++++-
Mdoc/package.json | 3++-
Adoc/src/app.svelte | 9+++++++++
Mdoc/src/app.ts | 6+++++-
Adoc/src/layout/main.svelte | 11+++++++++++
Adoc/src/page/home.svelte | 3+++
Adoc/src/page/not-found.svelte | 3+++
Adoc/watch.sh | 5+++++
10 files changed, 54 insertions(+), 21 deletions(-)

diff --git a/.github/workflows/docs-build-and-deploy.yml b/.github/workflows/docs-build-and-deploy.yml @@ -22,6 +22,8 @@ jobs: cd doc npm ci npm start + env: + PAGE_ROOT: '/pmlag/' - name: Deploy uses: JamesIves/github-pages-deploy-action@v4 diff --git a/doc/build.js b/doc/build.js @@ -6,6 +6,8 @@ const esbuildSvelte = require('esbuild-svelte'); const preprocess = require('svelte-preprocess'); const pkg = require('./package.json'); +const pageroot = process.env.PAGE_ROOT || ''; + // Simple for now const entryPoints = { 'app': 'src/app.ts' @@ -60,28 +62,15 @@ esbuild font-family: inherit; } </style> - ${styles.map(name => `<link rel="stylesheet" href="${name}"/>`).join('\n ')} + ${styles.map(name => `<link rel="stylesheet" href="${pageroot}${name}"/>`).join('\n ')} </head> <body> - ${buildList.map(name => `<script defer src="${name}"></script>`).join('\n ')} + ${buildList.map(name => `<script defer src="${pageroot}${name}"></script>`).join('\n ')} </body> </html> `); - }); - -// fs.writeFileSync(__dirname + `/dist/index.html`, ` -// <!DOCTYPE html> -// <html> -// <head> -// <meta charset="utf-8"> -// <title>${pkg.description}</title> -// <meta name="viewport" content="width=device-width, initial-scale=1"> -// ${styles.map(name => `<link rel="stylesheet" href="${name}"/>`).join('')} -// ${buildList.map(name => `<script defer src="${name}"></script>`).join('')} -// </head> -// <body> -// </body> -// </html> -// `); + // Copy index.html to 404.html + fs.writeFileSync(config.outdir + '/404.html', fs.readFileSync(config.outdir + '/index.html')); + }); diff --git a/doc/package-lock.json b/doc/package-lock.json @@ -12,7 +12,8 @@ "esbuild": "^0.17.11", "esbuild-svelte": "^0.7.3", "fast-glob": "^3.2.12", - "svelte-preprocess": "^5.0.2" + "svelte-preprocess": "^5.0.2", + "tinro": "^0.6.12" } }, "node_modules/@esbuild/android-arm": { @@ -864,6 +865,11 @@ } } }, + "node_modules/tinro": { + "version": "0.6.12", + "resolved": "https://registry.npmjs.org/tinro/-/tinro-0.6.12.tgz", + "integrity": "sha512-YYLh0a21GXXpS66ilZbywfXcPTKQQ+bv3tihoqKqSFQP6/F11N7ZmtRbFWcyZXXPFRSzNxmPJBB8ZhP0GkoS0Q==" + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", diff --git a/doc/package.json b/doc/package.json @@ -14,6 +14,7 @@ "esbuild": "^0.17.11", "esbuild-svelte": "^0.7.3", "fast-glob": "^3.2.12", - "svelte-preprocess": "^5.0.2" + "svelte-preprocess": "^5.0.2", + "tinro": "^0.6.12" } } diff --git a/doc/src/app.svelte b/doc/src/app.svelte @@ -0,0 +1,9 @@ +<script> + import { Route } from 'tinro'; + + import HomePage from './page/home.svelte'; + import NotFoundPage from './page/not-found.svelte'; +</script> + +<Route path="/"><HomePage/></Route> +<Route fallback><NotFoundPage/></Route> diff --git a/doc/src/app.ts b/doc/src/app.ts @@ -1 +1,5 @@ -console.log('hello world'); +import App from './app.svelte'; + +const app = new App({ + target: document.body, +}); diff --git a/doc/src/layout/main.svelte b/doc/src/layout/main.svelte @@ -0,0 +1,11 @@ +<script> + import { Route } from 'svelte-router-spa'; + export let currentRoute; + const params = {}; + + console.log({ currentRoute }); +</script> + +<main> + <Route {currentRoute} {params} /> +</main> diff --git a/doc/src/page/home.svelte b/doc/src/page/home.svelte @@ -0,0 +1,3 @@ +<div> + home page!!! +</div> diff --git a/doc/src/page/not-found.svelte b/doc/src/page/not-found.svelte @@ -0,0 +1,3 @@ +<div> + not found!!! +</div> diff --git a/doc/watch.sh b/doc/watch.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +while inotifywait --recursive --event modify src; do + npm start +done