Skip to content

Commit

Permalink
Make a Wish Foundation. Shovel hear my plea.
Browse files Browse the repository at this point in the history
  • Loading branch information
brainkim committed Mar 22, 2023
1 parent ba19526 commit 5ffedca
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 15 deletions.
43 changes: 36 additions & 7 deletions website/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"scripts": {
"build": "ts-node-esm src/build.ts && echo crank.js.org > dist/CNAME",
"watch": "nodemon --exec ts-node-esm src/build.ts -e 'js,ts,css,md' --ignore dist",
"serve": "shovel src/serve.ts --port 1338",
"serve": "shovel develop src/app.ts --port 1338",
"static": "http-server dist -p 1337 -c-1",
"predeploy": "npm run build",
"deploy": "gh-pages -d dist"
},
"dependencies": {
"@b9g/crank": "file:../dist",
"@b9g/revise": "file:../../revise/dist",
"@b9g/shovel": "^0.1.1",
"@b9g/shovel": "^0.1.2",
"@babel/core": "^7.21.0",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.21.0",
Expand Down
19 changes: 16 additions & 3 deletions website/src/serve.ts → website/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import {jsx} from "@b9g/crank/standalone";
import {renderer} from "@b9g/crank/html";
import {renderStylesToString} from "@emotion/server";

//import {Request, Response} from "@remix-run/web-fetch";

import {router} from "./routes.js";
import {Storage} from "./components/esbuild.js";
import {collectDocuments} from "./models/document.js";

const __dirname = new URL(".", import.meta.url).pathname;
const storage = new Storage({
Expand All @@ -17,7 +16,7 @@ const storage = new Storage({
});

export default {
fetch: async (req: Request) => {
async fetch(req: Request) {
console.info("serving", req.url);
const path = new URL(req.url).pathname;
if (path.startsWith(storage.publicPath)) {
Expand Down Expand Up @@ -55,4 +54,18 @@ export default {
headers: {"Content-Type": "text/html"},
});
},

async staticPaths() {
const blogDocs = await collectDocuments(
Path.join(__dirname, "../documents/blog"),
Path.join(__dirname, "../documents"),
);
const guideDocs = await collectDocuments(
Path.join(__dirname, "../documents/guides"),
Path.join(__dirname, "../documents"),
);
const blogURLs = blogDocs.map((doc) => doc.url);
const guideURLs = guideDocs.map((doc) => doc.url);
return ["/", "/blog", "/playground", ...guideURLs, ...blogURLs];
},
};
3 changes: 1 addition & 2 deletions website/src/components/code-editor.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {jsx} from "@b9g/crank/standalone";
import type {Context, Element as CrankElement} from "@b9g/crank";
import {css} from "@emotion/css";

import {Edit} from "@b9g/revise/edit.js";

import {Keyer} from "@b9g/revise/keyer.js";
import {EditHistory} from "@b9g/revise/history.js";

import type {ContentAreaElement} from "@b9g/revise/contentarea.js";

import type {Token} from "prismjs";
Expand Down
1 change: 0 additions & 1 deletion website/src/views/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type {ViewProps} from "../router.js";
import {collectDocuments} from "../models/document.js";

const __dirname = new URL(".", import.meta.url).pathname;

export default async function BlogPage({url, context: {storage}}: ViewProps) {
const posts = await collectDocuments(
path.join(__dirname, "../../documents/blog"),
Expand Down

0 comments on commit 5ffedca

Please sign in to comment.