Skip to content

Commit 4b14d0c

Browse files
committed
Example markdown
1 parent d5da3bf commit 4b14d0c

4 files changed

Lines changed: 33 additions & 1 deletion

File tree

src/example.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export const demoMarkdown = `# s3collab
2+
3+
Edit a document with anyone, in real time. No sign-up, no servers -- just a static page and an S3 bucket.
4+
5+
Share the link and start typing on the left. Your changes show up here on the right, for everyone.
6+
7+
## How it works
8+
9+
Every edit is stored as an operation in a shared log on S3. When two people edit at the same time, S3's **conditional writes** detect the conflict -- the second writer rebases against the first and retries automatically. No server needed.
10+
11+
## The stack
12+
13+
- **Storage & sync**: S3 conditional puts (\`If-Match\`)
14+
- **Auth**: Cognito identity pool (anonymous)
15+
- **Hosting**: GitHub Pages
16+
- **Backend**: *there is no backend*
17+
`

src/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ async function main() {
2929
/** @type {(text: string) => void} */
3030
let setRemote = noop
3131

32+
renderPreview(previewEl, '')
33+
3234
const engine = new SyncEngine({
3335
client,
3436
config,

src/preview.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
import { marked } from 'marked'
2+
import { demoMarkdown } from './example.js'
3+
4+
const demoHtml = marked.parse(demoMarkdown, { async: false, breaks: true, gfm: true })
25

36
/**
47
* @param {HTMLElement} el
58
* @param {string} markdown
69
*/
710
export function renderPreview(el, markdown) {
8-
el.innerHTML = marked.parse(markdown, { async: false, breaks: true, gfm: true })
11+
if (markdown) {
12+
el.classList.remove('demo')
13+
el.innerHTML = marked.parse(markdown, { async: false, breaks: true, gfm: true })
14+
} else {
15+
el.classList.add('demo')
16+
el.innerHTML = demoHtml
17+
}
918
}

src/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,7 @@ main {
8686
}
8787

8888
#preview h1, #preview h2, #preview h3 { margin-top: 1.2em }
89+
90+
#preview.demo {
91+
opacity: 0.55;
92+
}

0 commit comments

Comments
 (0)