Skip to content

Commit

Permalink
beta.5
Browse files Browse the repository at this point in the history
  • Loading branch information
sjc5 committed Oct 23, 2023
1 parent 2e7f7a7 commit 04c29f9
Show file tree
Hide file tree
Showing 36 changed files with 779 additions and 477 deletions.
8 changes: 8 additions & 0 deletions .changeset/light-carpets-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"create-hwy": patch
"@hwy-js/build": patch
"hwy": patch
"@hwy-js/dev": patch
---

update types
1 change: 1 addition & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"changesets": [
"early-readers-rule",
"famous-adults-push",
"light-carpets-cough",
"neat-moles-brush",
"poor-phones-lie",
"rude-kiwis-approve"
Expand Down
7 changes: 7 additions & 0 deletions docs/hwy.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
dev: {
port: 1270,
watchExclusions: ["src/styles/tw-output.bundle.css"],
},
deploymentTarget: "vercel-lambda",
};
24 changes: 12 additions & 12 deletions docs/package-lock.json

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

6 changes: 3 additions & 3 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"@hono/node-server": "^1.2.0",
"highlight.js": "^11.9.0",
"hono": "^3.8.3",
"hwy": "0.4.2-beta.4"
"hwy": "0.4.2-beta.5"
},
"devDependencies": {
"@hwy-js/build": "0.4.2-beta.4",
"@hwy-js/dev": "0.4.2-beta.4",
"@hwy-js/build": "0.4.2-beta.5",
"@hwy-js/dev": "0.4.2-beta.5",
"@types/node": "^20.8.7",
"@types/nprogress": "^0.2.2",
"htmx.org": "^1.9.6",
Expand Down
7 changes: 7 additions & 0 deletions docs/src/client.entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const __window = window;
import htmx from "htmx.org";
__window.htmx = htmx;
import NProgress from "nprogress";
__window.NProgress = NProgress;
// @ts-ignore
import("htmx.org/dist/ext/head-support.js");
6 changes: 6 additions & 0 deletions docs/src/components/anchor-heading.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { jsx as _jsx, jsxs as _jsxs } from "hono/jsx/jsx-runtime";
function AnchorHeading({ content }) {
const slugified = encodeURIComponent(content.toLowerCase().replace(/ /g, "-"));
return (_jsxs("div", { class: "flex gap-3 text-xl font-bold pt-4", id: slugified, children: [_jsx("a", { class: "hover:underline text-[#777] hover:text-[unset]", href: `#${slugified}`, children: "#" }), content] }));
}
export { AnchorHeading };
5 changes: 5 additions & 0 deletions docs/src/components/bold-italic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { jsx as _jsx } from "hono/jsx/jsx-runtime";
function Boldtalic({ children }) {
return (_jsx("b", { children: _jsx("i", { children: children }) }));
}
export { Boldtalic };
13 changes: 13 additions & 0 deletions docs/src/components/code-block.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { jsx as _jsx, jsxs as _jsxs } from "hono/jsx/jsx-runtime";
import hljs from "highlight.js/lib/core";
import typescript from "highlight.js/lib/languages/typescript";
import bash from "highlight.js/lib/languages/bash";
import json from "highlight.js/lib/languages/json";
const lang_map = { typescript, bash, json };
function CodeBlock({ language, code }) {
hljs.registerLanguage(language, lang_map[language]);
return (_jsxs("pre", { class: "overflow-x-auto rounded-2xl bg-slate-800 border-4 border-solid border-[#7777] py-4 px-5 max-w-full flex gap-5 text-white", children: [_jsx("code", { class: `language-${language}`, dangerouslySetInnerHTML: {
__html: hljs.highlight(code.trim(), { language }).value,
} }), _jsx("div", {})] }));
}
export { CodeBlock };
9 changes: 9 additions & 0 deletions docs/src/components/dialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { jsx as _jsx, jsxs as _jsxs } from "hono/jsx/jsx-runtime";
function DialogModal({ open_button_inner, dialog_inner, wrapper_class, open_button_class, }) {
return (_jsxs("div", { "hx-boost": "false", class: wrapper_class, children: [_jsx("button", { onclick: `this.nextElementSibling.showModal()`, class: open_button_class, children: open_button_inner }), _jsx("dialog", { onclick: "event.target==this && this.close()", style: {
padding: String(0),
border: "none",
background: "transparent",
}, children: _jsx("form", { method: "dialog", children: dialog_inner }) })] }));
}
export { DialogModal };
2 changes: 1 addition & 1 deletion docs/src/components/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function DialogModal({
<dialog
onclick="event.target==this && this.close()"
style={{
padding: 0,
padding: String(0),
border: "none",
background: "transparent",
}}
Expand Down
6 changes: 6 additions & 0 deletions docs/src/components/fallback-error-boundary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { jsx as _jsx, jsxs as _jsxs } from "hono/jsx/jsx-runtime";
import { Paragraph } from "./paragraph.js";
function FallbackErrorBoundary(props) {
return (_jsxs("div", { class: "space-y-4", children: [_jsx(Paragraph, { children: "Whoops, something went wrong. Sorry about that." }), _jsx(Paragraph, { children: "If you're feeling generous, please file an issue telling us what happened." })] }));
}
export { FallbackErrorBoundary };
8 changes: 8 additions & 0 deletions docs/src/components/inline-code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { jsx as _jsx } from "hono/jsx/jsx-runtime";
import { cx } from "../utils/utils.js";
function InlineCode({ children, high_contrast, ...rest }) {
return (_jsx("code", { ...rest, class: cx("py-[2px] px-1 whitespace-nowrap", high_contrast
? "bg-black text-white dark:bg-white dark:text-black"
: "bg-[#7772] dark:bg-[#7773] rounded", rest.class), children: children }));
}
export { InlineCode };
2 changes: 1 addition & 1 deletion docs/src/components/inline-code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function InlineCode({
high_contrast
? "bg-black text-white dark:bg-white dark:text-black"
: "bg-[#7772] dark:bg-[#7773] rounded",
rest.class
rest.class,
)}
>
{children}
Expand Down
5 changes: 5 additions & 0 deletions docs/src/components/nav.js

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

6 changes: 6 additions & 0 deletions docs/src/components/paragraph.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { jsx as _jsx } from "hono/jsx/jsx-runtime";
import { cx } from "../utils/utils.js";
function Paragraph({ children, ...rest }) {
return (_jsx("p", { ...rest, class: cx("leading-7", rest.class), children: children }));
}
export { Paragraph };
9 changes: 9 additions & 0 deletions docs/src/components/unordered-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { jsx as _jsx } from "hono/jsx/jsx-runtime";
import { cx } from "../utils/utils.js";
function UnorderedList({ children, ...rest }) {
return (_jsx("ul", { ...rest, class: cx("space-y-6", rest.class), children: children }));
}
function ListItem({ children, ...rest }) {
return (_jsx("li", { ...rest, class: cx("list-disc ml-6 pl-1 leading-7", rest.class), children: children }));
}
export { UnorderedList, ListItem };
89 changes: 89 additions & 0 deletions docs/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { jsx as _jsx, jsxs as _jsxs } from "hono/jsx/jsx-runtime";
import { IS_DEV } from "./utils/constants.js";
import { hwyInit, CssImports, rootOutlet, DevLiveRefreshScript, ClientScripts, HeadElements, getDefaultBodyProps, renderRoot, } from "hwy";
import { Hono } from "hono";
import { serve } from "@hono/node-server";
import { handle } from "@hono/node-server/vercel";
import { serveStatic } from "@hono/node-server/serve-static";
import { Nav } from "./components/nav.js";
import { logger } from "hono/logger";
import { secureHeaders } from "hono/secure-headers";
import { FallbackErrorBoundary } from "./components/fallback-error-boundary.js";
const app = new Hono();
app.use("*", logger());
app.get("*", secureHeaders());
await hwyInit({
app,
importMetaUrl: import.meta.url,
serveStatic,
/*
* The publicUrlPrefix makes the monorepo work with the public
* folder when deployed with Vercel. If you aren't using a
* monorepo (or aren't deploying to Vercel), you won't need
* to add a publicUrlPrefix.
*/
publicUrlPrefix: process.env.NODE_ENV === "production" ? "docs/" : undefined,
});
const default_head_blocks = [
{ title: "Hwy Framework" },
{
tag: "meta",
props: {
name: "description",
content: "Hwy is a simple, lightweight, and flexible web framework, built on Hono and HTMX.",
},
},
{
tag: "link",
props: {
rel: "icon",
href: `data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 16 16'><text x='0' y='14'>🔥</text></svg>`,
},
},
{
tag: "meta",
props: {
name: "og:image",
content: "/create-hwy-snippet.webp",
},
},
{
tag: "meta",
props: {
name: "htmx-config",
content: JSON.stringify({
selfRequestsOnly: true,
refreshOnHistoryMiss: true,
scrollBehavior: "auto",
}),
},
},
];
app.all("*", async (c, next) => {
if (IS_DEV)
await new Promise((r) => setTimeout(r, 150));
// 31 days vercel edge cache (invalidated each deploy)
c.header("CDN-Cache-Control", "public, max-age=2678400");
// 10 seconds client cache
c.header("Cache-Control", "public, max-age=10");
return await renderRoot(c, next, async ({ activePathData }) => {
return (_jsxs("html", { lang: "en", children: [_jsxs("head", { children: [_jsx("meta", { charset: "UTF-8" }), _jsx("meta", { name: "viewport", content: "width=device-width,initial-scale=1" }), _jsx(HeadElements, { c: c, activePathData: activePathData, defaults: default_head_blocks }), _jsx(CssImports, {}), _jsx(ClientScripts, { activePathData: activePathData }), _jsx(DevLiveRefreshScript, {})] }), _jsx("body", { ...getDefaultBodyProps({ nProgress: true }), class: "p-2 sm:p-4 flex", children: _jsxs("div", { class: "px-5 lg:px-8 w-full flex flex-col", children: [_jsxs("div", { class: "grow", children: [_jsx(Nav, {}), _jsx("div", { class: "flex flex-col gap-8 lg:gap-12 max-w-[640px] mb-8 mt-12 mx-auto", children: await rootOutlet({
c,
activePathData,
fallbackErrorBoundary: FallbackErrorBoundary,
}) })] }), _jsx("footer", { class: "text-xs border-t border-t-solid border-1 border-[#7773] pt-3 pb-4 shrink mt-6", children: _jsx("span", { class: "opacity-60", children: "MIT License. Copyright (c) 2023 Samuel J. Cook." }) })] }) })] }));
});
});
app.notFound((c) => {
return c.text("404 Not Found", 404);
});
app.onError((error, c) => {
console.error(error);
return c.text("500 Internal Server Error", 500);
});
export default handle(app);
if (IS_DEV) {
serve({ fetch: app.fetch, port: Number(process.env.PORT || 3000) }, (info) => {
console.log(`\nListening on http://${IS_DEV ? "localhost" : info.address}:${info.port}\n`);
});
}
4 changes: 4 additions & 0 deletions docs/src/pages/$.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { jsx as _jsx, jsxs as _jsxs } from "hono/jsx/jsx-runtime";
export default function () {
return (_jsxs("div", { children: [_jsx("h2", { class: "text-6xl", children: "404" }), _jsx("p", { class: "mt-4 mb-8", children: "Nothing found!" })] }));
}
28 changes: 28 additions & 0 deletions docs/src/pages/_index.page.js

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

Loading

0 comments on commit 04c29f9

Please sign in to comment.