create-rush-cms 0.0.1 → 0.1.0
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/LICENSE +21 -0
- package/README.md +58 -2
- package/dist/cli.js +209 -0
- package/package.json +14 -5
- package/template/.env.example +5 -0
- package/template/README.md +127 -0
- package/template/_gitignore +6 -0
- package/template/astro.config.ts +28 -0
- package/template/package.json +28 -0
- package/template/public/favicon.svg +4 -0
- package/template/src/astro-modules.d.ts +5 -0
- package/template/src/components/language-switcher.astro +39 -0
- package/template/src/components/nav-links.astro +33 -0
- package/template/src/components/site-footer.astro +29 -0
- package/template/src/components/site-header.astro +36 -0
- package/template/src/layouts/base.astro +49 -0
- package/template/src/lib/locale.ts +12 -0
- package/template/src/lib/route-page.ts +15 -0
- package/template/src/pages/404.astro +17 -0
- package/template/src/pages/[...locale]/contact.astro +59 -0
- package/template/src/pages/[...path].astro +32 -0
- package/template/src/pages/robots.txt.ts +10 -0
- package/template/src/pages/sitemap.xml.ts +4 -0
- package/template/src/styles/global.css +278 -0
- package/template/src/views/collection.astro +84 -0
- package/template/src/views/entry.astro +65 -0
- package/template/src/views/home.astro +160 -0
- package/template/src/views/index.ts +41 -0
- package/template/src/views/not-found.astro +21 -0
- package/template/tsconfig.json +9 -0
- package/index.js +0 -3
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { getRush, getUrls, homepageTitle } from '@rushcms/astro'
|
|
3
|
+
import Seo from '@rushcms/astro/components/seo.astro'
|
|
4
|
+
import Base from '../layouts/base.astro'
|
|
5
|
+
import type { HomeViewProps } from './index'
|
|
6
|
+
|
|
7
|
+
type Props = HomeViewProps
|
|
8
|
+
|
|
9
|
+
type Step = {
|
|
10
|
+
title: string
|
|
11
|
+
body: string
|
|
12
|
+
code: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { page } = Astro.props
|
|
16
|
+
const { locale, homepage } = page
|
|
17
|
+
const urls = getUrls(Astro)
|
|
18
|
+
const rush = getRush(Astro)
|
|
19
|
+
const site = await rush.site.get()
|
|
20
|
+
const collections = (await rush.collections.list()).filter((collection) => urls.routed(collection))
|
|
21
|
+
const title = homepageTitle(homepage) === undefined ? site.name : undefined
|
|
22
|
+
|
|
23
|
+
const steps: Step[] = [
|
|
24
|
+
{
|
|
25
|
+
title: 'Shape your URLs',
|
|
26
|
+
body: 'Replace the catch-all route with one route per public collection, so data-only collections stay off the site.',
|
|
27
|
+
code: "routes: { posts: '/{locale}/blog/{slug}' }"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
title: 'Fill the menus',
|
|
31
|
+
body: 'Create the navigations "main" and "footer" in Rush CMS. The header and footer pick them up on the next build.',
|
|
32
|
+
code: "getNavigation(Astro, 'main')"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
title: 'Add a contact form',
|
|
36
|
+
body: 'Create a form with the key "contact". It appears at /contact, with validation and spam protection handled for you.',
|
|
37
|
+
code: "forms.get('contact')"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
title: 'Go live',
|
|
41
|
+
body: 'Set your domain in site and security.allowedDomains, count the proxies in front of the server, then build.',
|
|
42
|
+
code: 'npm run build'
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
<Base locale={locale} title={title}>
|
|
48
|
+
{homepage && <Seo slot="head" homepage={homepage} />}
|
|
49
|
+
<div lang="en">
|
|
50
|
+
<section class="relative overflow-hidden border-b border-line">
|
|
51
|
+
<div
|
|
52
|
+
aria-hidden="true"
|
|
53
|
+
class="pointer-events-none absolute inset-x-0 -top-40 mx-auto h-96 max-w-4xl rounded-full bg-accent-soft opacity-70 blur-3xl"
|
|
54
|
+
>
|
|
55
|
+
</div>
|
|
56
|
+
<div class="relative mx-auto max-w-6xl px-6 py-24 sm:py-32">
|
|
57
|
+
<p
|
|
58
|
+
class="inline-flex items-center gap-2 rounded-full border border-line bg-surface px-3 py-1 text-sm text-muted"
|
|
59
|
+
>
|
|
60
|
+
<span class="size-2 rounded-full bg-emerald-500" aria-hidden="true"></span>
|
|
61
|
+
Connected to {site.name}
|
|
62
|
+
</p>
|
|
63
|
+
<h1 class="mt-6 max-w-3xl text-4xl font-semibold tracking-tight text-balance sm:text-6xl">
|
|
64
|
+
Your Rush CMS site is up and running.
|
|
65
|
+
</h1>
|
|
66
|
+
<p class="mt-6 max-w-2xl text-lg text-pretty text-muted">
|
|
67
|
+
Collection lists, entries, menus, the sitemap and redirects all come from your CMS. This
|
|
68
|
+
front page is yours to replace: it is a plain Astro view with no CMS content.
|
|
69
|
+
</p>
|
|
70
|
+
<div class="mt-10 flex flex-wrap gap-3">
|
|
71
|
+
<a href="#next-steps" class="button button-primary">See what is next</a>
|
|
72
|
+
{
|
|
73
|
+
collections[0] && (
|
|
74
|
+
<a href={urls.collection(collections[0], locale)} class="button button-secondary">
|
|
75
|
+
Browse {collections[0].name}
|
|
76
|
+
</a>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
</section>
|
|
82
|
+
|
|
83
|
+
<section aria-labelledby="content-heading" class="mx-auto max-w-6xl px-6 py-20">
|
|
84
|
+
<h2 id="content-heading" class="text-2xl font-semibold tracking-tight">Your content</h2>
|
|
85
|
+
{
|
|
86
|
+
collections.length > 0 ? (
|
|
87
|
+
<ul class="mt-8 grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
|
88
|
+
{collections.map((collection) => (
|
|
89
|
+
<li>
|
|
90
|
+
<a href={urls.collection(collection, locale)} class="card group block h-full">
|
|
91
|
+
<span class="block text-lg font-medium group-hover:text-accent">
|
|
92
|
+
{collection.name}
|
|
93
|
+
</span>
|
|
94
|
+
<span class="mt-1 block text-sm text-muted">
|
|
95
|
+
{urls.collection(collection, locale)}
|
|
96
|
+
</span>
|
|
97
|
+
</a>
|
|
98
|
+
</li>
|
|
99
|
+
))}
|
|
100
|
+
</ul>
|
|
101
|
+
) : (
|
|
102
|
+
<p class="mt-4 max-w-2xl text-muted">
|
|
103
|
+
No collection has a route yet. Create a collection in Rush CMS, or check the routes
|
|
104
|
+
in astro.config.ts.
|
|
105
|
+
</p>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
</section>
|
|
109
|
+
|
|
110
|
+
<section
|
|
111
|
+
id="next-steps"
|
|
112
|
+
aria-labelledby="next-steps-heading"
|
|
113
|
+
class="border-y border-line bg-surface"
|
|
114
|
+
>
|
|
115
|
+
<div class="mx-auto max-w-6xl px-6 py-20">
|
|
116
|
+
<h2 id="next-steps-heading" class="text-2xl font-semibold tracking-tight">What next</h2>
|
|
117
|
+
<ol class="mt-8 grid gap-6 md:grid-cols-2">
|
|
118
|
+
{
|
|
119
|
+
steps.map((step, index) => (
|
|
120
|
+
<li class="flex gap-4">
|
|
121
|
+
<span
|
|
122
|
+
aria-hidden="true"
|
|
123
|
+
class="flex size-9 shrink-0 items-center justify-center rounded-full bg-accent font-semibold text-accent-ink"
|
|
124
|
+
>
|
|
125
|
+
{index + 1}
|
|
126
|
+
</span>
|
|
127
|
+
<div>
|
|
128
|
+
<h3 class="font-medium">{step.title}</h3>
|
|
129
|
+
<p class="mt-1 text-muted">{step.body}</p>
|
|
130
|
+
<code class="mt-3 inline-block rounded-md bg-canvas px-2 py-1 font-mono text-sm">
|
|
131
|
+
{step.code}
|
|
132
|
+
</code>
|
|
133
|
+
</div>
|
|
134
|
+
</li>
|
|
135
|
+
))
|
|
136
|
+
}
|
|
137
|
+
</ol>
|
|
138
|
+
</div>
|
|
139
|
+
</section>
|
|
140
|
+
|
|
141
|
+
<section aria-labelledby="edit-heading" class="mx-auto max-w-6xl px-6 py-20">
|
|
142
|
+
<div class="grid gap-10 md:grid-cols-[1fr_auto] md:items-center">
|
|
143
|
+
<div>
|
|
144
|
+
<h2 id="edit-heading" class="text-2xl font-semibold tracking-tight">Edit this page</h2>
|
|
145
|
+
<p class="mt-4 max-w-2xl text-muted">
|
|
146
|
+
This page lives in <code class="font-mono text-ink">src/views/home.astro</code>. Replace
|
|
147
|
+
it with your own design, or render the homepage you build in Rush CMS from{' '}
|
|
148
|
+
<code class="font-mono text-ink">page.homepage.content</code>. List and entry pages
|
|
149
|
+
use <code class="font-mono text-ink">src/views/collection.astro</code> and{' '}
|
|
150
|
+
<code class="font-mono text-ink">src/views/entry.astro</code>; give a collection its
|
|
151
|
+
own views in <code class="font-mono text-ink">src/views/index.ts</code>.
|
|
152
|
+
</p>
|
|
153
|
+
</div>
|
|
154
|
+
<p class="rounded-xl border border-dashed border-line px-5 py-4 text-sm text-muted">
|
|
155
|
+
Documentation: coming soon
|
|
156
|
+
</p>
|
|
157
|
+
</div>
|
|
158
|
+
</section>
|
|
159
|
+
</div>
|
|
160
|
+
</Base>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { CollectionPage, HomepagePage } from '@rushcms/astro'
|
|
2
|
+
import type { CollectionRef, Entry, LocaleCode, RushUrls } from '@rushcms/client'
|
|
3
|
+
import GenericList from './collection.astro'
|
|
4
|
+
import GenericEntry from './entry.astro'
|
|
5
|
+
|
|
6
|
+
export type HomeViewProps = {
|
|
7
|
+
page: HomepagePage
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type ListViewProps = {
|
|
11
|
+
page: CollectionPage
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type EntryViewProps = {
|
|
15
|
+
entry: Entry
|
|
16
|
+
locale: LocaleCode
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type ListView = (props: ListViewProps) => unknown
|
|
20
|
+
|
|
21
|
+
export type EntryView = (props: EntryViewProps) => unknown
|
|
22
|
+
|
|
23
|
+
export type CollectionViews = {
|
|
24
|
+
list: ListView
|
|
25
|
+
entry: EntryView
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type ViewMap = Record<string, Partial<CollectionViews>>
|
|
29
|
+
|
|
30
|
+
const generic: CollectionViews = { list: GenericList, entry: GenericEntry }
|
|
31
|
+
|
|
32
|
+
// TODO: map a collection id or slug (any locale) to its own views, e.g. `posts: { entry: PostView }`.
|
|
33
|
+
const views: ViewMap = {}
|
|
34
|
+
|
|
35
|
+
export function viewsFor(collection: CollectionRef | undefined, urls: RushUrls): CollectionViews {
|
|
36
|
+
const key =
|
|
37
|
+
collection === undefined
|
|
38
|
+
? undefined
|
|
39
|
+
: urls.collectionKeys(collection).find((candidate) => Object.hasOwn(views, candidate))
|
|
40
|
+
return { ...generic, ...(key === undefined ? {} : views[key]) }
|
|
41
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { getLocale, getRush, getUrls } from '@rushcms/astro'
|
|
3
|
+
import Base from '../layouts/base.astro'
|
|
4
|
+
|
|
5
|
+
const locale = getLocale(Astro)
|
|
6
|
+
const site = await getRush(Astro).site.get()
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
<Base locale={locale} title={`Page not found | ${site.name}`}>
|
|
10
|
+
<meta slot="head" name="robots" content="noindex" />
|
|
11
|
+
<div lang="en" class="mx-auto flex max-w-3xl flex-col items-start px-6 py-24 sm:py-32">
|
|
12
|
+
<p class="font-mono text-sm text-accent">404</p>
|
|
13
|
+
<h1 class="mt-4 text-4xl font-semibold tracking-tight sm:text-5xl">Page not found</h1>
|
|
14
|
+
<p class="mt-6 text-lg text-muted">
|
|
15
|
+
The page you are looking for does not exist or is no longer available.
|
|
16
|
+
</p>
|
|
17
|
+
<a href={getUrls(Astro).homepage(locale)} class="button button-primary mt-10">
|
|
18
|
+
Back to the home page
|
|
19
|
+
</a>
|
|
20
|
+
</div>
|
|
21
|
+
</Base>
|
package/index.js
DELETED