@openelement/create 0.43.2 → 0.44.0-beta.1
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.
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/cli.js +1 -1
- package/src/template-builder.js +36 -12
- package/src/version.js +2 -2
- package/templates/README.tmpl +19 -11
- package/templates/app/components/page-404.tsx +22 -0
- package/templates/app/components/page-blog-index.tsx +35 -0
- package/templates/app/components/page-blog-welcome.tsx +54 -0
- package/templates/app/components/page-contact.tsx +46 -0
- package/templates/app/components/page-freshness.tsx +22 -0
- package/templates/app/components/page-home.tsx +55 -0
- package/templates/app/components/page-styles.ts +64 -0
- package/templates/app/islands/app-shell.tsx +58 -0
- package/templates/app/islands/my-counter.tsx +25 -26
- package/templates/app/islands/only-ticker.tsx +21 -27
- package/templates/app/routes/404.tsx +4 -38
- package/templates/app/routes/blog/index.tsx +5 -71
- package/templates/app/routes/blog/welcome.tsx +7 -0
- package/templates/app/routes/contact.tsx +17 -79
- package/templates/app/routes/freshness.tsx +9 -39
- package/templates/app/routes/index.tsx +4 -99
- package/templates/deno.json.tmpl +1 -1
- package/templates/vite.config.ts +69 -18
- package/templates/app/components/app-shell.tsx +0 -61
- package/templates/app/routes/blog/[slug].tsx +0 -79
- package/templates/content/blog/welcome.md +0 -14
package/templates/vite.config.ts
CHANGED
|
@@ -4,14 +4,78 @@ import deno from '@deno/vite-plugin';
|
|
|
4
4
|
|
|
5
5
|
// Design tokens (from Open Props) plus the global baseline. `--brand` must
|
|
6
6
|
// stay aligned with the ui package tokens (`--violet-6` in
|
|
7
|
-
// packages/ui/src/open-props-tokens.css).
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
7
|
+
// packages/ui/src/open-props-tokens.css).
|
|
8
|
+
//
|
|
9
|
+
// v0.44 styling model: the compiled serializer never inlines styles into SSR
|
|
10
|
+
// output; `static styles` sheets apply when an element activates client-side.
|
|
11
|
+
// Page classes are not registered client-side, so page rules live here in the
|
|
12
|
+
// document baseline, scoped under each page's host tag (pages use light
|
|
13
|
+
// roots). The app shell and islands carry their own `static styles` and are
|
|
14
|
+
// styled as soon as they hydrate.
|
|
11
15
|
const globalStyle =
|
|
12
16
|
'<style>:root{--paper:#faf9f6;--ink:#1c1b17;--ink-2:#5b594f;--line:#e5e2d8;--gray-0:#f8f9fa;--gray-1:#f1f3f5;--gray-3:#dee2e6;--gray-5:#adb5bd;--gray-7:#495057;--gray-9:#212529;--brand:#8262db;--brand-2:#4f8ef7;--size-1:4px;--size-2:8px;--size-3:12px;--size-4:16px;--border-size-1:1px;--radius-2:8px;--radius-3:14px;--font-sans:system-ui,-apple-system,sans-serif;--font-serif:ui-serif,Georgia,"Times New Roman",serif;--font-mono:ui-monospace,SFMono-Regular,Menlo,monospace;--font-size-0:0.875rem;--font-weight-5:500;--shadow-1:0 1px 3px 0 rgb(0 0 0 / 0.08);--shadow-2:0 10px 28px rgb(80 70 160 / 0.12)}' +
|
|
13
17
|
'body{margin:0;background:var(--paper);color:var(--ink);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}' +
|
|
14
18
|
'::selection{background:#8262db2e}' +
|
|
19
|
+
// Home page (index-page)
|
|
20
|
+
'index-page{display:block}' +
|
|
21
|
+
'index-page .hero{padding:2.5rem 0 1rem}' +
|
|
22
|
+
'index-page .eyebrow{color:var(--brand);font-weight:600;font-size:0.78rem;letter-spacing:0.14em;text-transform:uppercase}' +
|
|
23
|
+
'index-page h1{font-family:var(--font-serif);font-size:3rem;line-height:1.12;letter-spacing:-0.015em;margin:0.75rem 0 1.25rem;font-weight:700}' +
|
|
24
|
+
'index-page .lede{font-size:1.15rem;line-height:1.75;color:var(--ink-2);max-width:58ch;margin:0}' +
|
|
25
|
+
'index-page .lede code{font-size:0.85em}' +
|
|
26
|
+
'index-page .more{display:inline-block;margin-top:1.5rem;font-weight:600}' +
|
|
27
|
+
'index-page .demo{margin-top:2.75rem;border:1px solid var(--line);border-radius:8px;padding:1.25rem 1.5rem}' +
|
|
28
|
+
'index-page .demo .label{color:var(--ink-2);font-size:0.8rem;letter-spacing:0.1em;text-transform:uppercase;margin:0 0 0.9rem}' +
|
|
29
|
+
'index-page .recent{margin-top:3rem}' +
|
|
30
|
+
'index-page .recent h2{font-family:var(--font-serif);letter-spacing:-0.01em;margin:0 0 0.25rem}' +
|
|
31
|
+
'index-page .recent .sub{color:var(--ink-2);font-size:0.925rem;margin:0 0 1.5rem}' +
|
|
32
|
+
'index-page .recent .sub code{font-size:0.85em}' +
|
|
33
|
+
// Shared post-list rules (home teaser + blog index)
|
|
34
|
+
'index-page .posts,blog-index .posts{list-style:none;padding:0;margin:0;border-top:1px solid var(--line)}' +
|
|
35
|
+
'index-page .post,blog-index .post{display:block;padding:1.15rem 0;border-bottom:1px solid var(--line);color:inherit;text-decoration:none}' +
|
|
36
|
+
'index-page a.post:hover .title,blog-index a.post:hover .title{color:var(--brand)}' +
|
|
37
|
+
'index-page .post .title,blog-index .post .title{display:block;font-family:var(--font-serif);font-size:1.3rem;font-weight:700;letter-spacing:-0.01em;color:var(--ink);transition:color 0.15s ease}' +
|
|
38
|
+
'index-page .post .meta,blog-index .post .meta{display:block;margin-top:0.3rem;font-size:0.85rem;color:var(--ink-2)}' +
|
|
39
|
+
'index-page .post .excerpt,blog-index .post .excerpt{display:block;margin-top:0.45rem;color:var(--ink-2);line-height:1.6}' +
|
|
40
|
+
'index-page a{color:var(--brand);text-decoration:none}' +
|
|
41
|
+
'index-page a:hover{text-decoration:underline}' +
|
|
42
|
+
// Blog index (blog-index)
|
|
43
|
+
'blog-index{display:block}' +
|
|
44
|
+
'blog-index .eyebrow{color:var(--brand);font-weight:600;font-size:0.78rem;letter-spacing:0.14em;text-transform:uppercase}' +
|
|
45
|
+
'blog-index h1{font-family:var(--font-serif);letter-spacing:-0.015em;margin:0.5rem 0}' +
|
|
46
|
+
'blog-index .sub{color:var(--ink-2);font-size:0.925rem;margin:0 0 1.5rem}' +
|
|
47
|
+
'blog-index .sub code{font-size:0.85em}' +
|
|
48
|
+
'blog-index a{color:var(--brand);text-decoration:none}' +
|
|
49
|
+
// Blog post page (blog-welcome)
|
|
50
|
+
'blog-welcome{display:block}' +
|
|
51
|
+
'blog-welcome h1{font-family:var(--font-serif);font-size:2.4rem;line-height:1.15;letter-spacing:-0.015em;margin:0.5rem 0}' +
|
|
52
|
+
'blog-welcome .meta{color:var(--ink-2);font-size:0.9rem;margin-top:0;padding-bottom:1.5rem;border-bottom:1px solid var(--line)}' +
|
|
53
|
+
'blog-welcome a{color:var(--brand);text-decoration:none}' +
|
|
54
|
+
'blog-welcome .post-body{line-height:1.8;font-size:1.05rem}' +
|
|
55
|
+
'blog-welcome .post-body h2{font-family:var(--font-serif);margin:2.5rem 0 0.75rem;letter-spacing:-0.01em}' +
|
|
56
|
+
'blog-welcome .post-body p{margin:1rem 0}' +
|
|
57
|
+
'blog-welcome .post-body code{font-family:var(--font-mono,ui-monospace,Menlo,monospace);font-size:0.85em;background:#f1efe8;border:1px solid var(--line);padding:0.1em 0.4em;border-radius:5px}' +
|
|
58
|
+
// Freshness proof (freshness-page)
|
|
59
|
+
'freshness-page{display:block;max-width:800px;margin:2rem auto;padding:0 1rem}' +
|
|
60
|
+
'freshness-page p{color:var(--ink-2)}' +
|
|
61
|
+
// Styled 404 (el-404)
|
|
62
|
+
'el-404{display:block}' +
|
|
63
|
+
'el-404 h1{font-family:var(--font-serif);font-size:2.4rem;letter-spacing:-0.015em;margin:0.75rem 0 0.5rem;font-weight:700}' +
|
|
64
|
+
'el-404 p{color:var(--ink-2);line-height:1.6}' +
|
|
65
|
+
'el-404 a{color:var(--brand);font-weight:600;text-decoration:none}' +
|
|
66
|
+
'el-404 a:hover{text-decoration:underline}' +
|
|
67
|
+
// Contact form (contact-page)
|
|
68
|
+
'contact-page{display:block}' +
|
|
69
|
+
'contact-page h1{font-family:var(--font-serif);font-size:2.4rem;letter-spacing:-0.015em;margin:0.75rem 0 0.5rem;font-weight:700}' +
|
|
70
|
+
'contact-page .sub{color:var(--ink-2);line-height:1.6;max-width:52ch;margin:0 0 1.75rem}' +
|
|
71
|
+
'contact-page form{display:flex;gap:0.6rem;flex-wrap:wrap}' +
|
|
72
|
+
'contact-page input{font:inherit;min-width:16rem;padding:0.55rem 0.8rem;color:var(--ink);border:1px solid var(--line);border-radius:6px;background:#fff;transition:border-color 0.15s ease,box-shadow 0.15s ease}' +
|
|
73
|
+
'contact-page input:focus{outline:none;border-color:var(--brand);box-shadow:0 0 0 3px #8262db2e}' +
|
|
74
|
+
'contact-page button{font:inherit;font-weight:600;padding:0.55rem 1.1rem;cursor:pointer;border:1px solid var(--brand);border-radius:6px;background:var(--brand);color:#fff;transition:opacity 0.15s ease}' +
|
|
75
|
+
'contact-page button:hover{opacity:0.88}' +
|
|
76
|
+
'contact-page #error{color:#c92a2a;margin:1rem 0 0}' +
|
|
77
|
+
'contact-page #error:empty,contact-page #thanks:empty{display:none}' +
|
|
78
|
+
'contact-page #thanks{color:var(--brand);font-weight:600;margin:1rem 0 0}' +
|
|
15
79
|
'</style>';
|
|
16
80
|
|
|
17
81
|
export default defineConfig({
|
|
@@ -20,7 +84,7 @@ export default defineConfig({
|
|
|
20
84
|
html: { title: 'My openElement App' },
|
|
21
85
|
appShell: {
|
|
22
86
|
tagName: 'app-shell',
|
|
23
|
-
import: './app/
|
|
87
|
+
import: './app/islands/app-shell.tsx',
|
|
24
88
|
props: {
|
|
25
89
|
siteName: 'My openElement App',
|
|
26
90
|
},
|
|
@@ -30,19 +94,6 @@ export default defineConfig({
|
|
|
30
94
|
globalStyle,
|
|
31
95
|
],
|
|
32
96
|
},
|
|
33
|
-
content: {
|
|
34
|
-
blog: {
|
|
35
|
-
contentDir: 'content/blog',
|
|
36
|
-
basePath: '/blog',
|
|
37
|
-
},
|
|
38
|
-
nav: {
|
|
39
|
-
routesDir: 'app/routes',
|
|
40
|
-
headerNav: [
|
|
41
|
-
{ href: '/', label: 'Home' },
|
|
42
|
-
{ href: '/blog', label: 'Blog' },
|
|
43
|
-
],
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
97
|
}),
|
|
47
98
|
deno(),
|
|
48
99
|
],
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource @openelement/element */
|
|
2
|
-
import { defineElement } from '@openelement/app';
|
|
3
|
-
import { StyleSheet } from '@openelement/element';
|
|
4
|
-
|
|
5
|
-
export const tagName = 'app-shell';
|
|
6
|
-
|
|
7
|
-
interface HeaderNavLink {
|
|
8
|
-
href: string;
|
|
9
|
-
label: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// Fallback when vite.config.ts content.nav.headerNav is not configured.
|
|
13
|
-
const defaultNav: HeaderNavLink[] = [
|
|
14
|
-
{ href: '/freshness', label: 'Freshness' },
|
|
15
|
-
{ href: '/api/health', label: 'API health' },
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
const styles = new StyleSheet();
|
|
19
|
-
styles.replaceSync(`
|
|
20
|
-
:host { display: block; min-height: 100vh; }
|
|
21
|
-
header { border-bottom: 1px solid var(--line); }
|
|
22
|
-
.bar { max-width: 740px; margin: 0 auto; padding: 1.15rem 1.25rem; display: flex; justify-content: space-between; align-items: baseline; }
|
|
23
|
-
.brand { font-family: var(--font-serif); font-weight: 700; font-size: 1.2rem; letter-spacing: -0.01em; color: var(--ink); }
|
|
24
|
-
.brand:hover { text-decoration: none; color: var(--brand); }
|
|
25
|
-
nav { display: flex; gap: 1.5rem; }
|
|
26
|
-
nav a { color: var(--ink-2); font-size: 0.95rem; font-weight: 500; }
|
|
27
|
-
nav a:hover { color: var(--brand); text-decoration: none; }
|
|
28
|
-
main { max-width: 740px; margin: 0 auto; padding: 3rem 1.25rem 4rem; }
|
|
29
|
-
footer { border-top: 1px solid var(--line); color: var(--ink-2); font-size: 0.85rem; }
|
|
30
|
-
.foot { max-width: 740px; margin: 0 auto; padding: 1.25rem; display: flex; justify-content: space-between; gap: 1rem; }
|
|
31
|
-
a { color: var(--brand); text-decoration: none; }
|
|
32
|
-
a:hover { text-decoration: underline; }
|
|
33
|
-
`);
|
|
34
|
-
|
|
35
|
-
export default defineElement(tagName, {
|
|
36
|
-
styles,
|
|
37
|
-
render(props: { siteName?: string; headerNav?: HeaderNavLink[] }) {
|
|
38
|
-
const nav = props.headerNav?.length ? props.headerNav : defaultNav;
|
|
39
|
-
return (
|
|
40
|
-
<>
|
|
41
|
-
<header data-open-layout='app-shell'>
|
|
42
|
-
<div class='bar'>
|
|
43
|
-
<a class='brand' href='/'>{props.siteName ?? 'openElement'}</a>
|
|
44
|
-
<nav>
|
|
45
|
-
{nav.map((link) => <a key={link.href} href={link.href}>{link.label}</a>)}
|
|
46
|
-
</nav>
|
|
47
|
-
</div>
|
|
48
|
-
</header>
|
|
49
|
-
<main>
|
|
50
|
-
<slot></slot>
|
|
51
|
-
</main>
|
|
52
|
-
<footer>
|
|
53
|
-
<div class='foot'>
|
|
54
|
-
<span>Generated by @openelement/create.</span>
|
|
55
|
-
<a href='https://github.com/open-element/openelement'>GitHub</a>
|
|
56
|
-
</div>
|
|
57
|
-
</footer>
|
|
58
|
-
</>
|
|
59
|
-
);
|
|
60
|
-
},
|
|
61
|
-
});
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource @openelement/element */
|
|
2
|
-
import { defineElement, definePage, notFound } from '@openelement/app';
|
|
3
|
-
import { StyleSheet } from '@openelement/element';
|
|
4
|
-
import { getPostBySlug, posts } from '@openelement/generated/blog-data';
|
|
5
|
-
|
|
6
|
-
// Names the content element below. definePage routes always register under
|
|
7
|
-
// the route-path tag; this export never drives page registration (#960).
|
|
8
|
-
export const tagName = 'blog-post-page';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Blog Post Page - dynamic route /blog/:slug.
|
|
12
|
-
*
|
|
13
|
-
* One page per post in content/blog is prerendered at build time:
|
|
14
|
-
* getStaticPaths() lists the params, render() reads the matching post from
|
|
15
|
-
* the generated blog-data module. Post HTML comes from markdown authored in
|
|
16
|
-
* this repo, so it is rendered through the explicit `trustedHtml` boundary.
|
|
17
|
-
*
|
|
18
|
-
* Note the scoped StyleSheet: pages render inside declarative shadow DOM, so
|
|
19
|
-
* document-level CSS would not reach the markdown typography below.
|
|
20
|
-
*/
|
|
21
|
-
export function getStaticPaths(): Array<Record<string, string>> {
|
|
22
|
-
return posts.map((post) => ({ slug: post.slug }));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const styles = new StyleSheet();
|
|
26
|
-
styles.replaceSync(`
|
|
27
|
-
:host { display: block; }
|
|
28
|
-
h1 { font-family: var(--font-serif); font-size: 2.4rem; line-height: 1.15; letter-spacing: -0.015em; margin: 0.5rem 0; }
|
|
29
|
-
.meta { color: var(--ink-2); font-size: 0.9rem; margin-top: 0; padding-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
|
|
30
|
-
a { color: var(--brand); text-decoration: none; }
|
|
31
|
-
.post-body { line-height: 1.8; font-size: 1.05rem; }
|
|
32
|
-
.post-body h2 { font-family: var(--font-serif); margin: 2.5rem 0 0.75rem; letter-spacing: -0.01em; }
|
|
33
|
-
.post-body p { margin: 1rem 0; }
|
|
34
|
-
.post-body pre { background: #f4f2ec; border: 1px solid var(--line); padding: 1rem 1.25rem; border-radius: 8px; overflow-x: auto; font-size: 0.875rem; line-height: 1.65; }
|
|
35
|
-
.post-body code { font-family: var(--font-mono, ui-monospace, Menlo, monospace); font-size: 0.85em; background: #f1efe8; border: 1px solid var(--line); padding: 0.1em 0.4em; border-radius: 5px; }
|
|
36
|
-
.post-body pre code { background: none; border: none; padding: 0; }
|
|
37
|
-
.post-body img { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
|
|
38
|
-
.post-body blockquote { margin-left: 0; padding-left: 1rem; border-left: 2px solid var(--brand); color: var(--ink-2); }
|
|
39
|
-
`);
|
|
40
|
-
|
|
41
|
-
defineElement(tagName, {
|
|
42
|
-
styles,
|
|
43
|
-
render(props: { slug: string }) {
|
|
44
|
-
const post = getPostBySlug(props.slug);
|
|
45
|
-
// #922: an unknown slug is a 404, not a 200 "Post not found" page — the
|
|
46
|
-
// request-time server entry translates the thrown notFound() into the
|
|
47
|
-
// status code (SEO + cache semantics).
|
|
48
|
-
if (!post) {
|
|
49
|
-
notFound(`Post not found: ${props.slug}`);
|
|
50
|
-
}
|
|
51
|
-
return (
|
|
52
|
-
<>
|
|
53
|
-
<p>
|
|
54
|
-
<a href='/blog'>← Back to the blog</a>
|
|
55
|
-
</p>
|
|
56
|
-
<h1>{post.frontmatter.title}</h1>
|
|
57
|
-
<p class='meta'>
|
|
58
|
-
<time>{post.frontmatter.date.slice(0, 10)}</time>
|
|
59
|
-
{(post.frontmatter.tags ?? []).length
|
|
60
|
-
? ' · ' + (post.frontmatter.tags ?? []).join(', ')
|
|
61
|
-
: ''}
|
|
62
|
-
</p>
|
|
63
|
-
<article class='post-body' innerHTML={post.html} trustedHtml></article>
|
|
64
|
-
</>
|
|
65
|
-
);
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
export default definePage({
|
|
70
|
-
route: { path: '/blog/:slug' },
|
|
71
|
-
head: { title: 'Blog — My openElement App' },
|
|
72
|
-
renderIntent: {
|
|
73
|
-
mode: 'static',
|
|
74
|
-
revalidate: false,
|
|
75
|
-
},
|
|
76
|
-
render({ params }) {
|
|
77
|
-
return <blog-post-page slug={params.slug} />;
|
|
78
|
-
},
|
|
79
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Welcome
|
|
3
|
-
date: 2026-01-01
|
|
4
|
-
excerpt: The starter blog is wired up — replace this file with your first post.
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
This starter keeps the blog content directory present so the default content
|
|
8
|
-
plugin configuration can build immediately. Write your own markdown files
|
|
9
|
-
here — frontmatter `title`, `date`, `tags`, and `excerpt` are picked up by
|
|
10
|
-
the blog index and the `/blog/:slug` page automatically.
|
|
11
|
-
|
|
12
|
-
The post page renders the frontmatter `title` as the page's H1 heading, so
|
|
13
|
-
keep the body's headings starting at `##` — a leading `# Heading` in the
|
|
14
|
-
markdown body would render a duplicate page title.
|