Skip to content

Commit

Permalink
docs: copy update
Browse files Browse the repository at this point in the history
  • Loading branch information
rossrobino committed Sep 18, 2024
1 parent 74f1827 commit 09ce78f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion apps/docs/src/server/content/_preview.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { html } from "client:page";

export const handler = async (req: Request) => {
return new Response(
html, // Bundled client application.
html, // bundled client application
{
headers: { "Content-Type": "text/html" },
},
Expand Down
12 changes: 6 additions & 6 deletions apps/docs/src/server/content/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@ Here's an example of how to serve your app using the result of your build using

```ts
// server.js
// Import the `handler` from the build output.
// import the `handler` from the build output
import { handler } from "./dist/server/app.js";
// Converts web handler to a Node compatible request listener.
// converts web handler to a Node compatible request listener
import { nodeListener } from "domco/listener";
import { createServer } from "node:http";
// `sirv` serves static assets.
// `sirv` serves static assets
import sirv from "sirv";

const assets = sirv("dist/client", {
etag: true,
setHeaders: (res, pathname) => {
// Serve `dist/client/_immutable/*` with immutable headers.
// serve `dist/client/_immutable/*` with immutable headers
if (pathname.startsWith("/_immutable/")) {
res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
}
},
});

const server = createServer((req, res) =>
// First, look for a static asset.
// first, look for a static asset
assets(req, res, () =>
// Fallthrough to the handler if static asset is not found.
// fallthrough to the handler if static asset is not found
nodeListener(handler)(req, res),
),
);
Expand Down
8 changes: 4 additions & 4 deletions apps/docs/src/server/content/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ import { html } from "client:page";
import type { Handler } from "domco";
import { Trouter, type Methods } from "trouter";

// Custom context variable.
// custom context variable
type Context = {
req: Request;
params: Record<string, string>;
};

// Custom handler/middleware.
// custom handler/middleware
type RouteHandler = (context: Context) => Promise<Response | void>;

const router = new Trouter<RouteHandler>();
Expand All @@ -82,10 +82,10 @@ export const handler: Handler = async (req) => {
const { handlers, params } = router.find(req.method as Methods, pathname);

for (const h of handlers) {
// Create context.
// create context
const context: Context = { req, params };

// Pass into handler.
// pass into handler
const res = await h(context);

if (res instanceof Response) {
Expand Down
6 changes: 3 additions & 3 deletions apps/docs/src/server/content/migrate.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,17 @@ Create a server entry `src/server/+app.tsx` file.

```tsx
// /src/server/+app.tsx
// Import your App.
// import your App
import App from "../app/App";
// Import the HTML page.
// import the HTML page
import { html } from "client:page";
import { StrictMode } from "react";
import { renderToString } from "react-dom/server";

export const handler = async (_req: Request) => {
return new Response(
html.replace(
"%root%", // replace the text "%root%" with the React App.
"%root%", // replace the text "%root%" with the React App
renderToString(
<StrictMode>
<App />
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/src/server/content/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ import { html as otherHtml } from "client:page/other";

export const handler = async (req: Request) => {
return new Response(
html, // Your Vite app.
html, // bundled client application
{
headers: { "Content-Type": "text/html" },
},
Expand Down

0 comments on commit 09ce78f

Please sign in to comment.