mirror of
https://github.com/He4eT/huge-link.git
synced 2026-05-05 00:47:27 +00:00
Initial commit
This commit is contained in:
commit
11523c975b
13 changed files with 15621 additions and 0 deletions
30
src/app.js
Normal file
30
src/app.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import {h} from 'preact'
|
||||
import {useState} from 'preact/hooks'
|
||||
import {Router} from 'preact-router'
|
||||
|
||||
import Editor from './routes/editor'
|
||||
import Post from './routes/post'
|
||||
|
||||
const App = () => {
|
||||
const [markdown, setMarkdown] = useState('')
|
||||
|
||||
return (<main>
|
||||
<Router>
|
||||
<Editor
|
||||
path='/'
|
||||
markdown={ markdown }
|
||||
{ ...{setMarkdown} } />
|
||||
<Post
|
||||
path='/preview/'
|
||||
mode='preview'
|
||||
payload={ markdown }
|
||||
{ ...{setMarkdown} } />
|
||||
<Post
|
||||
path='/p/:payload'
|
||||
mode='post'
|
||||
{ ...{setMarkdown} } />
|
||||
</Router>
|
||||
</main>)
|
||||
}
|
||||
|
||||
export default App
|
||||
4
src/index.js
Normal file
4
src/index.js
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import './style'
|
||||
import App from './app'
|
||||
|
||||
export default App
|
||||
21
src/manifest.json
Normal file
21
src/manifest.json
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "huge-link",
|
||||
"short_name": "huge-link",
|
||||
"start_url": "/",
|
||||
"display": "standalone",
|
||||
"orientation": "portrait",
|
||||
"background_color": "#fff",
|
||||
"theme_color": "#673ab8",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/assets/icons/android-chrome-192x192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "/assets/icons/android-chrome-512x512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
]
|
||||
}
|
||||
16
src/routes/editor/index.js
Normal file
16
src/routes/editor/index.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import {h} from 'preact'
|
||||
import {Link} from 'preact-router/match'
|
||||
|
||||
const Editor = ({markdown, setMarkdown}) => (
|
||||
<section>
|
||||
<textarea
|
||||
onInput={ ({target}) => setMarkdown(target.value) }>
|
||||
{ markdown }
|
||||
</textarea>
|
||||
|
||||
<Link href='/preview'>
|
||||
Preview
|
||||
</Link>
|
||||
</section>)
|
||||
|
||||
export default Editor
|
||||
33
src/routes/post/index.js
Normal file
33
src/routes/post/index.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import {h} from 'preact'
|
||||
import {Link} from 'preact-router/match'
|
||||
|
||||
const emptyControls = null
|
||||
const previewContorls = 'controls placeholder'
|
||||
|
||||
const noop = _ => _
|
||||
const decode = noop
|
||||
|
||||
const Post = ({mode, payload, setMarkdown}) => {
|
||||
const [controls, decodeFn] = {
|
||||
preview: [previewContorls, noop],
|
||||
post: [emptyControls, decode]
|
||||
}[mode]
|
||||
|
||||
const markdown = decodeFn(payload)
|
||||
|
||||
setMarkdown(markdown)
|
||||
|
||||
return (<section>
|
||||
{ controls }
|
||||
|
||||
<article>
|
||||
{ markdown }
|
||||
</article>
|
||||
|
||||
<Link href='/'>
|
||||
Edit post
|
||||
</Link>
|
||||
</section>)
|
||||
}
|
||||
|
||||
export default Post
|
||||
3
src/style/index.css
Normal file
3
src/style/index.css
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
html, body {
|
||||
|
||||
}
|
||||
4
src/sw.js
Normal file
4
src/sw.js
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import { getFiles, setupPrecaching, setupRouting } from 'preact-cli/sw/'
|
||||
|
||||
setupRouting()
|
||||
setupPrecaching(getFiles())
|
||||
15
src/template.html
Normal file
15
src/template.html
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title><% preact.title %></title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<link rel="apple-touch-icon" href="/assets/icons/apple-touch-icon.png">
|
||||
<% preact.headEnd %>
|
||||
</head>
|
||||
<body>
|
||||
<% preact.bodyEnd %>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue