mirror of
https://github.com/c8r/x0.git
synced 2024-08-16 17:00:24 +03:00
Add custom template example
This commit is contained in:
parent
01333369ab
commit
f518480fc0
20
examples/custom-template/README.md
Normal file
20
examples/custom-template/README.md
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
# x0 custom template example
|
||||
|
||||
```sh
|
||||
npm install
|
||||
```
|
||||
|
||||
## Dev Server
|
||||
|
||||
```sh
|
||||
npm start
|
||||
```
|
||||
|
||||
Editing `src/index.js` will live update in the development server.
|
||||
|
||||
## Static Build
|
||||
|
||||
```sh
|
||||
npm run build
|
||||
```
|
14
examples/custom-template/package.json
Normal file
14
examples/custom-template/package.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "x0-custom-template-example",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "x0 src -o",
|
||||
"build": "x0 build src"
|
||||
},
|
||||
"dependencies": {
|
||||
"@compositor/x0": "^5.0.0"
|
||||
},
|
||||
"x0": {
|
||||
"template": "./template.js"
|
||||
}
|
||||
}
|
7
examples/custom-template/src/index.js
Normal file
7
examples/custom-template/src/index.js
Normal file
@ -0,0 +1,7 @@
|
||||
import React from 'react'
|
||||
|
||||
const App = props => (
|
||||
<h1>Hello</h1>
|
||||
)
|
||||
|
||||
export default App
|
17
examples/custom-template/template.js
Normal file
17
examples/custom-template/template.js
Normal file
@ -0,0 +1,17 @@
|
||||
module.exports = ({
|
||||
html = '',
|
||||
css = '',
|
||||
scripts,
|
||||
meta = [],
|
||||
links = [],
|
||||
}) =>
|
||||
`<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta name='viewport' content='width=device-width,initial-scale=1'>
|
||||
<title>x0 Custom Template</title>
|
||||
${css}
|
||||
</head>
|
||||
<div id=root>${html}</div>
|
||||
${scripts}
|
||||
`
|
Loading…
Reference in New Issue
Block a user