-
Notifications
You must be signed in to change notification settings - Fork 14
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
22 changed files
with
279 additions
and
29 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
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 @@ | ||
--- | ||
'@umijs/tnf': patch | ||
--- | ||
|
||
feat: basic ssr |
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,11 @@ | ||
import { defineConfig } from '@umijs/tnf'; | ||
|
||
export default defineConfig({ | ||
router: { | ||
defaultPreload: 'intent', | ||
convention: { | ||
routeFileIgnorePattern: 'components', | ||
}, | ||
}, | ||
ssr: {}, | ||
}); |
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,17 @@ | ||
{ | ||
"name": "@examples/ssr", | ||
"private": true, | ||
"scripts": { | ||
"build": "tnf build", | ||
"dev": "tnf dev", | ||
"preview": "tnf preview" | ||
}, | ||
"dependencies": { | ||
"@types/react": "^18.3.12", | ||
"@types/react-dom": "^18.3.1", | ||
"@umijs/tnf": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.6.3" | ||
} | ||
} |
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,15 @@ | ||
const express = require('express'); | ||
const app = express(); | ||
|
||
app.use((req, res, next) => { | ||
if (req.url === '/' || req.url === '/foo') { | ||
return require('./dist/server.js').render(req, res); | ||
} | ||
next(); | ||
}); | ||
|
||
app.use(express.static('dist')); | ||
|
||
app.listen(7001, () => { | ||
console.log('Server is running on http://localhost:7001'); | ||
}); |
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,18 @@ | ||
import { Link, Outlet, createRootRoute } from '@umijs/tnf/router'; | ||
|
||
export const Route = createRootRoute({ | ||
component: () => ( | ||
<> | ||
<div>Hello</div> | ||
<ul> | ||
<li> | ||
<Link to="/">Home</Link> | ||
</li> | ||
<li> | ||
<Link to="/foo">Foo</Link> | ||
</li> | ||
</ul> | ||
<Outlet /> | ||
</> | ||
), | ||
}); |
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,3 @@ | ||
.foo { | ||
color: green; | ||
} |
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,11 @@ | ||
import { createFileRoute } from '@umijs/tnf/router'; | ||
|
||
function Home() { | ||
return ( | ||
<div> | ||
<h3>Welcome Home!</h3> | ||
</div> | ||
); | ||
} | ||
|
||
export default Home; |
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,27 @@ | ||
import { createFileRoute, useLoaderData } from '@umijs/tnf/router'; | ||
|
||
export const Route = createFileRoute('/foo')({ | ||
component: Foo, | ||
loader: async () => { | ||
const res = await fetch('https://dummyjson.com/users'); | ||
const data = await res.json(); | ||
return data; | ||
}, | ||
}); | ||
|
||
function Foo() { | ||
const { users } = useLoaderData({ | ||
from: '/foo', | ||
}); | ||
return ( | ||
<div> | ||
<h3>Welcome Foo!</h3> | ||
<p>Users</p> | ||
<ul> | ||
{users.map((user: any) => ( | ||
<li key={user.id}>{user.firstName}</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
} |
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 { createFileRoute } from '@umijs/tnf/router'; | ||
import Home from './components'; | ||
|
||
export const Route = createFileRoute('/')({ | ||
component: Home, | ||
}); |
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 @@ | ||
{ | ||
"extends": "./.tnf/tsconfig.json", | ||
"compilerOptions": {} | ||
|
||
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes | ||
// from the referenced tsconfig.json - TypeScript does not merge them in | ||
} |
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
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
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
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
Oops, something went wrong.