verso-cms 0.0.0-stage → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +168 -2
  3. package/bin/verso.js +16 -0
  4. package/editor/door.js +139 -0
  5. package/editor/editor.js +1880 -0
  6. package/editor/elevate.css +2158 -0
  7. package/editor/ext-attrs.js +87 -0
  8. package/editor/ext-blocks.js +422 -0
  9. package/editor/ext-builder.js +819 -0
  10. package/editor/ext-channels.js +574 -0
  11. package/editor/ext-components.js +160 -0
  12. package/editor/ext-history.js +242 -0
  13. package/editor/ext-palette.js +307 -0
  14. package/editor/ext-people.js +345 -0
  15. package/editor/ext-repeaters.js +143 -0
  16. package/editor/ext-screens.js +94 -0
  17. package/editor/ext-site-settings.js +318 -0
  18. package/editor/ext-site-view.js +632 -0
  19. package/editor/ext-tokens.js +1195 -0
  20. package/editor/new-page.js +252 -0
  21. package/editor/rich.js +23 -0
  22. package/package.json +69 -4
  23. package/src/blocks.js +269 -0
  24. package/src/box.js +339 -0
  25. package/src/build.js +210 -0
  26. package/src/cli.js +161 -0
  27. package/src/color.js +137 -0
  28. package/src/components.js +223 -0
  29. package/src/elevate.js +74 -0
  30. package/src/errors.js +46 -0
  31. package/src/extensions/README.md +70 -0
  32. package/src/extensions/blocks.js +294 -0
  33. package/src/extensions/builder.js +734 -0
  34. package/src/extensions/channels.js +341 -0
  35. package/src/extensions/components.js +141 -0
  36. package/src/extensions/history.js +169 -0
  37. package/src/extensions/palette.js +31 -0
  38. package/src/extensions/people.js +113 -0
  39. package/src/extensions/site-settings.js +251 -0
  40. package/src/extensions/site-view.js +381 -0
  41. package/src/extensions/tags.js +15 -0
  42. package/src/extensions/tokens.js +587 -0
  43. package/src/fonts.js +139 -0
  44. package/src/git.js +419 -0
  45. package/src/html-edit.js +942 -0
  46. package/src/images.js +116 -0
  47. package/src/people.js +286 -0
  48. package/src/rich.js +124 -0
  49. package/src/scaffold.js +185 -0
  50. package/src/screens.js +65 -0
  51. package/src/server.js +693 -0
  52. package/src/site.js +618 -0
  53. package/src/template.js +915 -0
  54. package/src/video.js +29 -0
  55. package/starter/Dockerfile +20 -0
  56. package/starter/README.md +49 -0
  57. package/starter/blocks/call-to-action.html +6 -0
  58. package/starter/blocks/features.html +15 -0
  59. package/starter/blocks/hero.html +8 -0
  60. package/starter/blocks/image-and-text.html +8 -0
  61. package/starter/blocks/latest-posts.html +20 -0
  62. package/starter/blocks/post-index.html +30 -0
  63. package/starter/blocks/quote.html +9 -0
  64. package/starter/blocks/site-footer.html +8 -0
  65. package/starter/blocks/site-nav.html +8 -0
  66. package/starter/blocks/tag-list.html +10 -0
  67. package/starter/blocks/tagged-posts.html +19 -0
  68. package/starter/blocks/team.html +15 -0
  69. package/starter/blocks/text.html +4 -0
  70. package/starter/content/404/page.json +21 -0
  71. package/starter/content/about/page.json +65 -0
  72. package/starter/content/journal/designing-for-the-morning-shift/body.html +22 -0
  73. package/starter/content/journal/designing-for-the-morning-shift/checklist.jpg +0 -0
  74. package/starter/content/journal/designing-for-the-morning-shift/cover.jpg +0 -0
  75. package/starter/content/journal/designing-for-the-morning-shift/page.json +17 -0
  76. package/starter/content/journal/page.json +19 -0
  77. package/starter/content/journal/the-first-week/body.html +17 -0
  78. package/starter/content/journal/the-first-week/cover.jpg +0 -0
  79. package/starter/content/journal/the-first-week/page.json +17 -0
  80. package/starter/content/journal/the-first-week/wall-of-cards.jpg +0 -0
  81. package/starter/content/page.json +94 -0
  82. package/starter/content/site.json +88 -0
  83. package/starter/content/studio-table.jpg +0 -0
  84. package/starter/content/topics/page.json +27 -0
  85. package/starter/dockerignore +5 -0
  86. package/starter/elevate/config/design.ts +30 -0
  87. package/starter/elevate/config/elevate.ts +16 -0
  88. package/starter/elevate/config/syntax.ts +6 -0
  89. package/starter/elevate/design/site.ts +9 -0
  90. package/starter/elevate/design/tokens.json +20 -0
  91. package/starter/elevate/extend/fonts.css +1 -0
  92. package/starter/gitignore +6 -0
  93. package/starter/netlify.toml +5 -0
  94. package/starter/parts/.gitkeep +0 -0
  95. package/starter/public/favicon.svg +1 -0
  96. package/starter/templates/page.html +20 -0
  97. package/starter/templates/page.layout.json +23 -0
  98. package/starter/templates/post.html +65 -0
  99. package/starter/verso.defaults.json +33 -0
  100. package/starter-blank/blocks/site-footer.html +3 -0
  101. package/starter-blank/blocks/site-nav.html +8 -0
  102. package/starter-blank/blocks/text.html +4 -0
  103. package/starter-blank/content/404/page.json +18 -0
  104. package/starter-blank/content/page.json +18 -0
  105. package/starter-blank/content/site.json +36 -0
  106. package/starter-blank/elevate/design/tokens.json +10 -0
  107. package/starter-blank/templates/page.html +17 -0
  108. package/starter-blank/verso.defaults.json +26 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kenneth Pickett
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,169 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/DesignInTheBlack/verso/main/docs/mark-dark.svg">
4
+ <img src="https://raw.githubusercontent.com/DesignInTheBlack/verso/main/docs/mark-light.svg" width="88" height="64" alt="">
5
+ </picture>
6
+ </p>
2
7
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
8
+ <h1 align="center">Verso</h1>
9
+
10
+ <p align="center"><strong>The page is the editor.</strong></p>
11
+
12
+ <p align="center">Build a website by clicking on it. Your design stays consistent,<br>
13
+ your content stays organised, and every change is a plain file in git.</p>
14
+
15
+ <p align="center">
16
+ <a href="https://www.npmjs.com/package/verso-cms"><img src="https://img.shields.io/npm/v/verso-cms?label=verso-cms&color=FF4F2B" alt="verso-cms on npm"></a>
17
+ <a href="https://www.npmjs.com/package/elevate-framework"><img src="https://img.shields.io/npm/v/elevate-framework?label=elevate-framework&color=1F3329" alt="elevate-framework on npm"></a>
18
+ <a href="https://github.com/DesignInTheBlack/verso/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-1F3329" alt="MIT license"></a>
19
+ </p>
20
+
21
+ <p align="center"><a href="https://verso-docs.creative-cd9.workers.dev"><strong>Website and docs</strong></a> · <a href="https://verso-docs.creative-cd9.workers.dev/docs/start/install/">Get started</a> · <a href="https://verso-docs.creative-cd9.workers.dev/llms.txt">For AI assistants</a></p>
22
+
23
+ <p align="center">
24
+ <img src="https://raw.githubusercontent.com/DesignInTheBlack/verso/main/docs/screenshots/hero.png" alt="Editing a page's headline in place, with Verso's bar at the bottom of the page">
25
+ </p>
26
+
27
+ ## Start a site
28
+
29
+ You need [Node.js](https://nodejs.org) 20.19 or newer and [git](https://git-scm.com).
30
+
31
+ ```bash
32
+ npx verso-cms new my-site
33
+ cd my-site
34
+ npm run dev
35
+ ```
36
+
37
+ Your site opens in the browser with the editor on it. Click any words to change them.
38
+
39
+ Add `--blank` to start from an empty site instead of the example.
40
+
41
+ <br>
42
+
43
+ ## Build the whole site in the browser
44
+
45
+ Start from a blank site and make everything it needs without opening a file: page types, the blocks pages are built from, the design, a blog. New pages start from a page type you pick by its preview.
46
+
47
+ Everything Verso makes is plain HTML in your repository. You can open any of it in your own editor, change it by hand, and keep working visually afterwards.
48
+
49
+ <p align="center">
50
+ <img src="https://raw.githubusercontent.com/DesignInTheBlack/verso/main/docs/screenshots/new-page.png" alt="The New page dialog, with each page type shown as a live preview">
51
+ </p>
52
+
53
+ <br>
54
+
55
+ ## Design and building are one system
56
+
57
+ Your colours, typefaces, sizes and spacing live in one place: the design. When you build a block, those are the only choices on offer. You pick from your palette and your type scale, never from a free-for-all colour picker or a box for pixel values.
58
+
59
+ Because every block draws from the same design, one change reaches the whole site. Make the accent warmer, or the headings larger, and every page that uses them follows.
60
+
61
+ <p align="center">
62
+ <img src="https://raw.githubusercontent.com/DesignInTheBlack/verso/main/docs/screenshots/one-system.png" alt="Left: the site's colours in the Design brand book. Right: the block builder, offering exactly those colours and type sizes for the selected headline">
63
+ </p>
64
+
65
+ The design opens as a brand book, set in your site's own fonts. Tuck it beside the page to try a colour and watch the site change before you save it.
66
+
67
+ <p align="center">
68
+ <img src="https://raw.githubusercontent.com/DesignInTheBlack/verso/main/docs/screenshots/brand-book.png" alt="Left: the brand book's cover. Right: a colour being tried with the book tucked beside the page">
69
+ </p>
70
+
71
+ <br>
72
+
73
+ ## Content that stays organised
74
+
75
+ - **Pages are folders.** `content/about/` is `/about/`. Its words and images live inside it and move with it.
76
+ - **Page types** give similar pages the same layout and the same fields to fill in.
77
+ - **Channels** turn a folder into a blog, a changelog or a portfolio: new posts, drafts, search, and an RSS feed.
78
+ - **Tags** group pages across folders, and each tag can have its own page.
79
+ - **Shared sections,** like the header and footer, are the same on every page. Change one anywhere and it changes everywhere.
80
+ - **Site view** shows every page as an outline or a map. Drag a page to move it, and its address and every link to it follow.
81
+
82
+ <p align="center">
83
+ <img src="https://raw.githubusercontent.com/DesignInTheBlack/verso/main/docs/screenshots/site-view.png" alt="Left: Site view as a map. Right: Site view as an outline, with one page's details">
84
+ </p>
85
+
86
+ <p align="center">
87
+ <img width="720" src="https://raw.githubusercontent.com/DesignInTheBlack/verso/main/docs/screenshots/channels.png" alt="The Channels panel, listing a changelog's posts with search and a drafts filter">
88
+ </p>
89
+
90
+ <br>
91
+
92
+ ## Built on Elevate
93
+
94
+ Verso's styles are written in [Elevate](https://elevate-docs.pages.dev), a CSS framework built on design tokens. It's the reason the editor can keep your design consistent.
95
+
96
+ **Classes read like design decisions.** Each class names a property and the values from your design, in any order:
97
+
98
+ ```html
99
+ <section class="contain col gap:d8 pd-t:c1 /md/ pd-t:c5">
100
+ <h1 class="font:display:regular:tight text:ink">{{ headline:text }}</h1>
101
+ <a class="pd:d3:d5 bg-color:ink text:paper @hover:[bg-color:accent]">Get started</a>
102
+ </section>
103
+ ```
104
+
105
+ **Only your design is allowed.** Every value has to be one of your tokens. A typo, or a colour that isn't in your palette, stops the build with the file and line, so it never reaches the live site:
106
+
107
+ ```
108
+ × blocks/hero.html, line 1
109
+ The class "bg-color:brand-red" isn't valid. Unable to determine modifier type for "brand-red"
110
+ Change or remove that class in the template.
111
+ ```
112
+
113
+ **Screen sizes are part of the class.** Everything after `/md/` applies from tablet width up. Layouts start on the smallest screens and change as the screen grows.
114
+
115
+ **Only the CSS you use is generated.** Elevate reads your templates and writes a stylesheet with just those classes.
116
+
117
+ **The editor uses the same tokens.** The colours in the block builder, the sizes in the type picker and the swatches in the brand book all come from the same design files that Elevate compiles.
118
+
119
+ <br>
120
+
121
+ ## How it's stored
122
+
123
+ A Verso site is a folder of ordinary files. The editor reads and writes them, and publishing commits them to git, so your site's history is the repository's history.
124
+
125
+ ```
126
+ my-site/
127
+ ├── content/ pages: one folder each, holding its words and images
128
+ ├── templates/ page types, as HTML
129
+ ├── blocks/ blocks, as HTML
130
+ ├── parts/ HTML shared by templates and blocks
131
+ ├── elevate/ the design: colours, fonts, sizes, spacing
132
+ └── verso.json site settings, text styles and channels
133
+ ```
134
+
135
+ <br>
136
+
137
+ ## Put it online
138
+
139
+ **As a static site.** Push the folder to GitHub and connect it to Cloudflare Pages or Netlify, with build command `npm run build` and output folder `dist`. Every Publish updates the live site.
140
+
141
+ **As a box.** `npm start` runs the site and its editor together at one address. You and the people you invite sign in at `/edit` and edit from any browser, and publishing is live in about a second. New sites include a Dockerfile. [More about boxes](https://github.com/DesignInTheBlack/verso/blob/main/docs/box.md).
142
+
143
+ <br>
144
+
145
+ ## Guides
146
+
147
+ The full documentation is on [the Verso website](https://verso-docs.creative-cd9.workers.dev/docs/), which is itself a Verso site. These guides cover the same ground in brief:
148
+
149
+ | | |
150
+ | --- | --- |
151
+ | **[Using the editor](https://github.com/DesignInTheBlack/verso/blob/main/docs/editor.md)** | Pages, blocks, the block builder, Design, Site view, channels, history and publishing |
152
+ | **[Writing templates](https://github.com/DesignInTheBlack/verso/blob/main/docs/templates.md)** | Fields, lists of pages, conditions, repeaters, tags, parts and scripts |
153
+ | **[Where things are kept](https://github.com/DesignInTheBlack/verso/blob/main/docs/files.md)** | Which file holds what, and what the build produces |
154
+ | **[Running a site as a box](https://github.com/DesignInTheBlack/verso/blob/main/docs/box.md)** | Sign-in, roles, working together and hosting |
155
+ | **[Working on Verso](https://github.com/DesignInTheBlack/verso/blob/main/docs/developing.md)** | Setting up, finding your way around the code, and running the tests |
156
+
157
+ ### For AI assistants
158
+
159
+ Point an assistant at [llms.txt](https://verso-docs.creative-cd9.workers.dev/llms.txt) before it builds a Verso site. It explains the files, the template language, the mistakes the build catches and how to fix them, and it links to [Elevate's own guide](https://elevate-docs.pages.dev/llms.txt). Everything in one file: [llms-full.txt](https://verso-docs.creative-cd9.workers.dev/llms-full.txt).
160
+
161
+ <br>
162
+
163
+ ## Status
164
+
165
+ Verso is at version 0.1. It runs [its own website](https://verso-docs.creative-cd9.workers.dev) and has a full test suite, but it hasn't yet been tried in every browser and on every system. If something breaks, please [open an issue](https://github.com/DesignInTheBlack/verso/issues).
166
+
167
+ ## License
168
+
169
+ [MIT](https://github.com/DesignInTheBlack/verso/blob/main/LICENSE)
package/bin/verso.js ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ // Checks Node's version before loading anything else, so an old Node gets a
3
+ // plain message instead of a crash from deep inside a dependency.
4
+ // The rest of the command line lives in src/cli.js.
5
+
6
+ const [major, minor] = process.versions.node.split('.').map(Number);
7
+ const supported = major >= 23 || (major === 22 && minor >= 12) || (major === 20 && minor >= 19);
8
+
9
+ if (!supported) {
10
+ const red = (s) => (process.stderr.isTTY ? `\x1b[31m${s}\x1b[0m` : s);
11
+ console.error(red(`× Verso needs Node.js 20.19 or newer, and this computer has ${process.versions.node}.`));
12
+ console.error(' Install the LTS version from https://nodejs.org, open a new terminal, and run this again.');
13
+ process.exit(1);
14
+ }
15
+
16
+ await import('../src/cli.js');
package/editor/door.js ADDED
@@ -0,0 +1,139 @@
1
+ // The pages in front of the editor on a boxed site (verso serve): signing
2
+ // in, setting up the first owner, and using an invite or new-password link.
3
+ //
4
+ // These are whole pages made on the server, plain forms that work without
5
+ // JavaScript. They live here, with the rest of the interface, so their
6
+ // classes are compiled into the editor's stylesheet with everything else.
7
+
8
+ const ui = (classes) => classes;
9
+ const esc = (s) => String(s ?? '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
10
+
11
+ const MARK = `<span class="${ui("row:x-center:y-center w:d12 h:d12 bd:round-full bg-color:proof text:paper child:no-shrink")}" aria-hidden="true"><svg width="26" height="26" viewBox="1 3 18 18"><path d="M5 6.5 10 17l5-10.5" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/></svg></span>`;
12
+
13
+ const LABEL = ui("font:small:medium text:ink");
14
+ const INPUT = ui("w:full h:d12 pd-x:d4 bd:round-d3 bd:width-px:solid:line bg-color:paper font:base text:ink @focus:[bd:proof_shadow:proof-focus_outline:none] transition:fast");
15
+ const BUTTON = ui("w:full h:d12 mg-t:d2 bd:width-0 bd:round-pill bg-color:proof text:paper font:base:semibold cursor:pointer @hover:[bg-color:proof-2] @focus-visible:[outline:d0:solid:ink] transition:fast");
16
+ const QUIET = ui("font:small text:ink-3:relaxed");
17
+ const LINK = ui("text:ink:underline @hover:[text:proof-2]");
18
+
19
+ const field = ({ name, label, type = 'text', value = '', autocomplete, hint = '', focus = false }) => `
20
+ <label class="${ui("col gap:d1")}">
21
+ <span class="${LABEL}">${label}</span>
22
+ <input class="${INPUT}" type="${type}" name="${name}" value="${esc(value)}" autocomplete="${autocomplete}" required${type === 'password' ? ' minlength="8" data-secret' : ''}${focus ? ' autofocus' : ''}>
23
+ ${hint ? `<span class="${ui("font:tiny text:ink-3")}">${hint}</span>` : ''}
24
+ </label>`;
25
+
26
+ // One box under the password: tick it to read what you typed.
27
+ const REVEAL = `
28
+ <label class="${ui("row:y-center gap:d2 font:small text:ink-3 cursor:pointer select:none")}" data-reveal hidden>
29
+ <input type="checkbox" class="${ui("w:d4 h:d4 cursor:pointer")}"> Show the password
30
+ </label>
31
+ <script>(() => { const box = document.querySelector('[data-reveal]'); box.hidden = false; box.querySelector('input').addEventListener('change', (e) => document.querySelectorAll('[data-secret]').forEach((i) => { i.type = e.target.checked ? 'text' : 'password'; })); })();</script>`;
32
+
33
+ const problem = (message) => (message
34
+ ? `<p role="alert" class="${ui("pd:d4:d3 bd:round-d3 bg-color:proof-soft font:small:medium text:proof-2")}">${esc(message)}</p>`
35
+ : '');
36
+
37
+ const page = ({ site, title, heading, intro = '', body }) => `<!DOCTYPE html>
38
+ <html lang="en">
39
+ <head>
40
+ <meta charset="utf-8">
41
+ <meta name="viewport" content="width=device-width, initial-scale=1">
42
+ <meta name="robots" content="noindex">
43
+ <title>${esc(title)} · ${esc(site)}</title>
44
+ <link rel="stylesheet" href="/__verso/elevate.css">
45
+ </head>
46
+ <body class="${ui("min-h:hScreen col:x-center pd:d5 bg-color:paper-2 font:ui:base text:ink /md/ pd-y:c2")}">
47
+ <main class="${ui("col gap:d8 w:full max-w:s1 mg-y:auto")}">
48
+ <header class="${ui("col gap:d5")}">
49
+ ${MARK}
50
+ <div class="${ui("col gap:d2")}">
51
+ <p class="${ui("font:small:medium text:ink-3")}">${esc(site)}</p>
52
+ <h1 class="${ui("font:h4:semibold text:ink:snug")}">${heading}</h1>
53
+ ${intro ? `<p class="${ui("font:base text:ink-3:relaxed")}">${intro}</p>` : ''}
54
+ </div>
55
+ </header>
56
+ ${body}
57
+ <p class="${QUIET}"><a class="${LINK}" href="/">Back to the site</a></p>
58
+ </main>
59
+ </body>
60
+ </html>`;
61
+
62
+ const form = (action, inner) => `<form method="post" action="${action}" class="${ui("col gap:d4")}">${inner}</form>`;
63
+
64
+ export function signInPage({ site, error = '', email = '', to = '' }) {
65
+ return page({
66
+ site,
67
+ title: 'Sign in',
68
+ heading: 'Sign in to edit',
69
+ body: `${form('/edit', `
70
+ ${problem(error)}
71
+ <input type="hidden" name="to" value="${esc(to)}">
72
+ ${field({ name: 'email', label: 'Email', type: 'email', value: email, autocomplete: 'username', focus: !email })}
73
+ ${field({ name: 'password', label: 'Password', type: 'password', autocomplete: 'current-password', focus: !!email })}
74
+ ${REVEAL}
75
+ <button class="${BUTTON}">Sign in</button>`)}
76
+ <p class="${QUIET}">Forgotten your password? Ask an owner of this site for a new link.</p>`,
77
+ });
78
+ }
79
+
80
+ // Nobody can edit yet, and the only way to become the first owner is the
81
+ // link the server wrote to its log.
82
+ export function notSetUpPage({ site }) {
83
+ return page({
84
+ site,
85
+ title: 'Set up editing',
86
+ heading: 'Editing isn\'t set up yet',
87
+ intro: 'When this site started, it wrote a setup link in its log. Open that link to become the site\'s first owner.',
88
+ body: `<p class="${ui("pd:d4 bd:round-d3 bg-color:paper bd:width-px:solid:line font:small text:ink-3:relaxed")}">Can't find it? Restart the site, or run <code class="${ui("pd:d1:d0 bd:round-d1 bg-color:paper-2 font:mono:small text:ink")}">npx verso owner</code> in its folder, and a fresh link is written.</p>`,
89
+ });
90
+ }
91
+
92
+ export function deadLinkPage({ site }) {
93
+ return page({
94
+ site,
95
+ title: 'Link not found',
96
+ heading: 'This link doesn\'t work any more',
97
+ intro: 'It has been used already, or it\'s more than seven days old. Ask an owner of the site for a new one.',
98
+ body: `<a href="/edit" class="${ui("row:x-center:y-center w:full h:d12 bd:round-pill bd:width-px:solid:line bg-color:paper font:base:semibold text:ink @hover:[bd:ink-3] @focus-visible:[outline:d0:solid:proof] transition:fast")}">Go to sign in</a>`,
99
+ });
100
+ }
101
+
102
+ // One page for the three kinds of link: the first owner's, an invite, and a
103
+ // new password.
104
+ export function joinPage({ site, link, token, error = '', values = {} }) {
105
+ const hidden = `<input type="hidden" name="t" value="${esc(token)}">`;
106
+ if (link.kind === 'reset') {
107
+ return page({
108
+ site,
109
+ title: 'New password',
110
+ heading: 'Choose a new password',
111
+ intro: `For ${esc(link.email)}. Your other browsers will be signed out.`,
112
+ body: form('/edit/join', `
113
+ ${problem(error)}${hidden}
114
+ <input type="hidden" name="email" value="${esc(link.email)}" autocomplete="username">
115
+ ${field({ name: 'password', label: 'New password', type: 'password', autocomplete: 'new-password', hint: 'At least 8 characters. A few words together works well.', focus: true })}
116
+ ${REVEAL}
117
+ <button class="${BUTTON}">Save and sign in</button>`),
118
+ });
119
+ }
120
+ const first = link.kind === 'setup';
121
+ const role = link.role === 'owner' ? 'an owner' : 'an editor';
122
+ return page({
123
+ site,
124
+ title: first ? 'Set up editing' : 'Join',
125
+ heading: first ? 'Set up editing' : `Start editing ${esc(site)}`,
126
+ intro: first
127
+ ? 'You\'ll be an owner of this site. Owners can change everything and invite other people.'
128
+ : `${link.by ? `${esc(link.by)} invited you` : 'You\'ve been invited'} as ${role}. Choose a password and you're in.`,
129
+ body: form('/edit/join', `
130
+ ${problem(error)}${hidden}
131
+ ${field({ name: 'name', label: 'Your name', value: values.name ?? link.name, autocomplete: 'name', focus: !(values.name ?? link.name) })}
132
+ ${first
133
+ ? field({ name: 'email', label: 'Email', type: 'email', value: values.email || '', autocomplete: 'username', hint: 'What you\'ll sign in with. Verso never sends email.' })
134
+ : `<div class="${ui("col gap:d1")}"><span class="${LABEL}">Email</span><span class="${ui("row:y-center h:d12 pd-x:d4 bd:round-d3 bg-color:line font:base text:ink-3")}">${esc(link.email)}</span><input type="hidden" name="email" value="${esc(link.email)}" autocomplete="username"></div>`}
135
+ ${field({ name: 'password', label: 'Password', type: 'password', autocomplete: 'new-password', hint: 'At least 8 characters. A few words together works well.', focus: !!(values.name ?? link.name) && !first })}
136
+ ${REVEAL}
137
+ <button class="${BUTTON}">${first ? 'Set up and start editing' : 'Start editing'}</button>`),
138
+ });
139
+ }