プレイグラウンド、サンドボックス、使い捨てスクリプト置き場
0

Configure Feed

Select the types of activity you want to include in your feed.

create wmr-ssg

Kohei Watanabe (Oct 13, 2021, 7:40 PM +0900) 254efe47 70c68198

+132
+3
wmr-ssg/.gitignore
··· 1 + /.cache/ 2 + /dist/ 3 + /node_modules/
+13
wmr-ssg/package.json
··· 1 + { 2 + "devDependencies": { 3 + "@exampledev/new.css": "^1.1.3", 4 + "@wmrjs/directory-import": "^0.3.0", 5 + "preact": "^10.5.15", 6 + "preact-iso": "^2.3.0", 7 + "wmr": "^3.7.2" 8 + }, 9 + "scripts": { 10 + "dev": "wmr", 11 + "build": "wmr build --prerender" 12 + } 13 + }
+14
wmr-ssg/public/index.html
··· 1 + <!DOCTYPE html> 2 + <html> 3 + <head> 4 + <meta charset="UTF-8" /> 5 + <title>wmr-ssg-example</title> 6 + <meta name="viewport" content="width=device-width" /> 7 + <link 8 + rel="stylesheet" 9 + href="https://cdn.jsdelivr.net/npm/@exampledev/new.css/new.min.css" 10 + /> 11 + <script type="module" src="main.tsx"></script> 12 + </head> 13 + <body></body> 14 + </html>
+48
wmr-ssg/public/main.tsx
··· 1 + import { 2 + LocationProvider, 3 + ErrorBoundary, 4 + Router, 5 + lazy, 6 + hydrate, 7 + prerender as ssr, 8 + } from "preact-iso"; 9 + 10 + // @ts-expect-error 11 + import pages from "dir:./pages"; 12 + 13 + const routes = (pages as string[]).map((name: string) => { 14 + const filename = name.replace(/\.tsx$/, ""); 15 + const url = `/${filename.replace(/_index$/, "")}`; 16 + const Route = lazy(() => import(`./pages/${filename}.tsx`)); 17 + 18 + console.log(url); 19 + 20 + return { url, Route }; 21 + }); 22 + 23 + function App() { 24 + return ( 25 + <LocationProvider> 26 + <header> 27 + <nav> 28 + <a href="/">Home</a> / <a href="/hello">Hello</a> 29 + </nav> 30 + </header> 31 + <ErrorBoundary> 32 + <Router> 33 + {routes.map(({ Route, url }) => ( 34 + <Route path={url} /> 35 + ))} 36 + </Router> 37 + </ErrorBoundary> 38 + </LocationProvider> 39 + ); 40 + } 41 + 42 + export async function prerender() { 43 + return await ssr(<App />); 44 + } 45 + 46 + if (typeof window !== "undefined") { 47 + hydrate(<App />, document.body); 48 + }
+5
wmr-ssg/public/pages/_index.tsx
··· 1 + export default () => ( 2 + <main> 3 + <h1>ようこそ!</h1> 4 + </main> 5 + );
+5
wmr-ssg/public/pages/hello.tsx
··· 1 + export default () => ( 2 + <main> 3 + <h1>Hello!</h1> 4 + </main> 5 + );
+13
wmr-ssg/tsconfig.json
··· 1 + { 2 + "compilerOptions": { 3 + "noEmit": true, 4 + "strict": true, 5 + "target": "esnext", 6 + "module": "esnext", 7 + "moduleResolution": "node", 8 + "lib": ["dom", "dom.iterable", "esnext"], 9 + "jsx": "preserve", 10 + "jsxImportSource": "preact" 11 + }, 12 + "include": ["public"] 13 + }
+3
wmr-ssg/wmr.config.ts
··· 1 + import directoryPlugin from "@wmrjs/directory-import"; 2 + 3 + export default directoryPlugin;
+28
wmr-ssg/yarn.lock
··· 1 + # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 + # yarn lockfile v1 3 + 4 + 5 + "@exampledev/new.css@^1.1.3": 6 + version "1.1.3" 7 + resolved "https://registry.yarnpkg.com/@exampledev/new.css/-/new.css-1.1.3.tgz#fcc1f15629db8cd105ad2e8c649095ca10623007" 8 + integrity sha512-qhbGfqBRwUlM6MCSaJdUfjq86opNCMvM+6kVvs6S0kYhy0V8dKbe4rDMIklEJGuMc5QH5OuPjdCReu9I0tim2w== 9 + 10 + "@wmrjs/directory-import@^0.3.0": 11 + version "0.3.0" 12 + resolved "https://registry.yarnpkg.com/@wmrjs/directory-import/-/directory-import-0.3.0.tgz#cb04113d43e22fcfe4515de14c46643f675b0a3d" 13 + integrity sha512-2Ga/v3/hDL8IOnwlvGax3fB/5+EeNT2JM/fGAFO6rtaiOWJ9GUI5TB+2Z3RRS8hYKEbP5PbEOuUMchObxDWeyA== 14 + 15 + preact-iso@^2.3.0: 16 + version "2.3.0" 17 + resolved "https://registry.yarnpkg.com/preact-iso/-/preact-iso-2.3.0.tgz#ab6c5de28df9e0f7a0589dd2175a83ba821f69ec" 18 + integrity sha512-taJmRidbWrjHEhoVoxXS2Kvxa6X3jXSsTtD7rSYeJuxnPNr1ghCu1JUzCrRxmZwTUNWIqwUpNi+AJoLtvCPN7g== 19 + 20 + preact@^10.5.15: 21 + version "10.5.15" 22 + resolved "https://registry.yarnpkg.com/preact/-/preact-10.5.15.tgz#6df94d8afecf3f9e10a742fd8c362ddab464225f" 23 + integrity sha512-5chK29n6QcJc3m1lVrKQSQ+V7K1Gb8HeQY6FViQ5AxCAEGu3DaHffWNDkC9+miZgsLvbvU9rxbV1qinGHMHzqA== 24 + 25 + wmr@^3.7.2: 26 + version "3.7.2" 27 + resolved "https://registry.yarnpkg.com/wmr/-/wmr-3.7.2.tgz#3d6dfb771fafc0e2119d4502aaea26ecd5963c19" 28 + integrity sha512-i+e/T8J067qP2pBgq6E2gaW9qMGK+D9eGue85YM0Vflc2UuzXBP3fSS5PzvyHEKuPHZWmcFBmZRs6DU9Lkr9og==