Skip to content
Myr

chore: update nano-jsx example (#97)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Yusuke Wada · committed by GitHub · parent 1b65c44 · Browse files · 15 files+174 added−150 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

15 files+174 added−150 removed

  • other:+174 added−150 removed

15 files+174 added−150 removed

added:examples/jsx-ssr/src/components/footer.tsx+11 added
added:examples/jsx-ssr/src/components/header.tsx+11 added
added:examples/jsx-ssr/src/pages/page.tsx+25 added
added:examples/jsx-ssr/src/pages/top.tsx+34 added
deleted:examples/jsx-ssr/src/Footer.jsx-7 removed
deleted:examples/jsx-ssr/src/Header.jsx-7 removed
deleted:examples/jsx-ssr/src/index.js-61 removed
added:examples/jsx-ssr/src/index.tsx+50 added
deleted:examples/jsx-ssr/src/Post.jsx-15 removed
1import { Header } from './Header'2import { Footer } from './Footer'34export const Post = (props) => {5 return (6 <div>7 <Header />8 <main>9 <h2>{props.post.title}</h2>10 <p>{props.post.body}</p>11 </main>12 <Footer />13 </div>14 )15}
added:examples/jsx-ssr/src/renderer.tsx+22 added
1import Nano from 'nano-jsx'2import { Helmet } from 'nano-jsx'34export const render = (component: any) => {5 const app = Nano.renderSSR(component)6 const { body, head, footer, attributes } = Helmet.SSR(app)7 const html = `8<!DOCTYPE html>9<html ${attributes.html.toString()}>10 <head>11 <meta charset="UTF-8">12 <meta name="viewport" content="width=device-width, initial-scale=1.0">13 <link rel='stylesheet' href='//cdnjs.cloudflare.com/ajax/libs/mini.css/3.0.1/mini-default.min.css' />14 ${head.join('\n')}15 </head>16 <body ${attributes.body.toString()} style="padding: 1em 2em">17 ${body}18 ${footer.join('\n')}19 </body>20</html>`21 return html22}
deleted:examples/jsx-ssr/src/Top.jsx-20 removed
1import { Header } from './Header'2import { Footer } from './Footer'34export const Top = (props) => {5 return (6 <div>7 <Header />8 <main>9 <h2>Posts</h2>10 {props.posts}11 <ul>12 {props.posts.map((post) => {13 return <li><a href={`/post/${post.id}`}>{post.title}</a></li>14 })}15 </ul>16 </main>17 <Footer />18 </div>19 )20}
modified:examples/jsx-ssr/package.json+10 added-12 removed
1{2 "name": "hono-example-jsx-ssr",3 "version": "0.0.1",4 "description": "",5 "main": "index.js",5 "main": "dist/index.js",6 "scripts": {7 "build": "tsc && wrangler build",8 "dev": "tsc && npm-run-all --parallel dev:*",9 "dev:tsc": "tsc --watch",10 "dev:wrangler": "wrangler dev",11 "test": "echo \"Error: no test specified\" && exit 1"7 "build": "esbuild --bundle --sourcemap --outdir=dist ./src/index.tsx",8 "dev": "miniflare --live-reload --debug",9 "publish": "wrangler publish dist/index.js"10 },11 "repository": {12 "type": "git",13 "url": "git+https://github.com/yusukebe/hono.git"
4 unmodified lines
18 "url": "https://github.com/yusukebe/hono/issues"19 },20 "homepage": "https://github.com/yusukebe/hono#readme",21 "dependencies": {24 "hono": "*",25 "nano-jsx": "^0.0.27"22 "hono": "^0.3.7",23 "nano-jsx": "^0.0.29"24 },25 "devDependencies": {28 "@cloudflare/wrangler": "^1.19.7",29 "npm-run-all": "^4.1.5",30 "typescript": "^4.5.4"26 "esbuild": "^0.14.20",27 "miniflare": "^2.2.0",28 "wrangler": "^0.0.16"29 }32}30}
modified:examples/jsx-ssr/tsconfig.json+3 added-17 removed
1{2 "compilerOptions": {3 "jsx": "react-jsx",4 "jsxImportSource": "nano-jsx/lib",5 "target": "es2017",6 "module": "commonjs",7 "rootDir": "src",8 "outDir": "./dist",9 "allowJs": true,10 "strict": true,11 "esModuleInterop": true,12 "skipLibCheck": true,13 },14 "include": [15 "src/**/*"16 ],17 "exclude": [18 "node_modules",19 ]3 "jsx": "react",4 "jsxFactory": "Nano.h",5 }6}
deleted:examples/jsx-ssr/webpack.config.js-4 removed
1module.exports = {2 target: 'webworker',3 entry: './dist/index.js',4}
modified:examples/jsx-ssr/wrangler.toml+8 added-7 removed
1name = "hono-example-jsx-ssr"2type = "webpack"3route = ''4zone_id = ''5usage_model = ''6compatibility_flags = []7workers_dev = true2type = "javascript"34compatibility_date = "2022-01-08"9webpack_config = "webpack.config.js"56[build]7command = "yarn run build"89[build.upload]10format = "service-worker"