-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
779 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!" })] })); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.