@ciderpress/ui 1.0.0-rc.3 → 1.0.0-rc.5
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/dist/index.d.ts +1 -1
- package/dist/index.mjs +4 -3
- package/dist/node.d.ts +1 -1
- package/dist/node.mjs +316 -50
- package/dist/theme/components/footer/site-footer.tsx +68 -9
- package/dist/theme/components/home/feature-card.tsx +5 -8
- package/dist/theme/components/home/feature.tsx +31 -11
- package/dist/theme/components/home/hero-demo-custom.tsx +116 -0
- package/dist/theme/components/home/hero-demo.css +27 -0
- package/dist/theme/components/home/layout.tsx +149 -26
- package/dist/theme/components/home/split-visual-custom.tsx +26 -0
- package/dist/theme/components/home/workspaces.tsx +39 -3
- package/dist/theme/components/nav/branch-tag.tsx +7 -7
- package/dist/theme/components/nav/ciderpress-header.css +2 -1
- package/dist/theme/components/nav/ciderpress-header.tsx +26 -3
- package/dist/theme/components/nav/ciderpress-nav-social-links.tsx +9 -7
- package/dist/theme/components/nav/floating-branch-indicator.tsx +7 -7
- package/dist/theme/components/nav/header-icon.css +24 -0
- package/dist/theme/components/nav/header-icon.tsx +119 -0
- package/dist/theme/components/nav/header-logo.css +16 -0
- package/dist/theme/components/nav/header-logo.tsx +200 -0
- package/dist/theme/components/nav/layout.tsx +45 -7
- package/dist/theme/components/nav/nav-logo.tsx +5 -1
- package/dist/theme/components/shared/card-icon.tsx +37 -0
- package/dist/theme/components/shared/ciderpress-logo.tsx +5 -1
- package/dist/theme/components/shared/icon.tsx +119 -35
- package/dist/theme/components/shared/resolve-card-icon.ts +53 -12
- package/dist/theme/components/shared/section-card.tsx +9 -6
- package/dist/theme/components/sidebar/sidebar-links.tsx +6 -2
- package/dist/theme/components/theme-provider.tsx +27 -11
- package/dist/theme/components/workspaces/card.tsx +7 -9
- package/dist/theme/hooks/use-ciderpress.ts +60 -5
- package/dist/theme/lib/read-social-links.ts +4 -3
- package/dist/theme/lib/theme-favicon.ts +1 -1
- package/dist/theme/lib/with-mount-base.ts +31 -0
- package/package.json +13 -13
- package/src/theme/components/footer/site-footer.tsx +68 -9
- package/src/theme/components/home/feature-card.tsx +5 -8
- package/src/theme/components/home/feature.tsx +31 -11
- package/src/theme/components/home/hero-demo-custom.tsx +116 -0
- package/src/theme/components/home/hero-demo.css +27 -0
- package/src/theme/components/home/layout.tsx +149 -26
- package/src/theme/components/home/split-visual-custom.tsx +26 -0
- package/src/theme/components/home/workspaces.tsx +39 -3
- package/src/theme/components/nav/branch-tag.tsx +7 -7
- package/src/theme/components/nav/ciderpress-header.css +2 -1
- package/src/theme/components/nav/ciderpress-header.tsx +26 -3
- package/src/theme/components/nav/ciderpress-nav-social-links.tsx +9 -7
- package/src/theme/components/nav/floating-branch-indicator.tsx +7 -7
- package/src/theme/components/nav/header-icon.css +24 -0
- package/src/theme/components/nav/header-icon.tsx +119 -0
- package/src/theme/components/nav/header-logo.css +16 -0
- package/src/theme/components/nav/header-logo.tsx +200 -0
- package/src/theme/components/nav/layout.tsx +45 -7
- package/src/theme/components/nav/nav-logo.tsx +5 -1
- package/src/theme/components/shared/card-icon.tsx +37 -0
- package/src/theme/components/shared/ciderpress-logo.tsx +5 -1
- package/src/theme/components/shared/icon.tsx +119 -35
- package/src/theme/components/shared/resolve-card-icon.ts +53 -12
- package/src/theme/components/shared/section-card.tsx +9 -6
- package/src/theme/components/sidebar/sidebar-links.tsx +6 -2
- package/src/theme/components/theme-provider.tsx +27 -11
- package/src/theme/components/workspaces/card.tsx +7 -9
- package/src/theme/hooks/use-ciderpress.ts +60 -5
- package/src/theme/lib/read-social-links.ts +4 -3
- package/src/theme/lib/theme-favicon.ts +1 -1
- package/src/theme/lib/with-mount-base.ts +31 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type { FooterConfig, HomeConfig,
|
|
1
|
+
import type { FooterConfig, HomeConfig, SerializedIcon } from '@ciderpress/config'
|
|
2
2
|
import { useSite } from '@rspress/core/runtime'
|
|
3
3
|
|
|
4
4
|
export interface CiderpressSidebarItem {
|
|
5
5
|
readonly text?: string
|
|
6
6
|
readonly link?: string
|
|
7
|
-
readonly icon?:
|
|
7
|
+
readonly icon?: SerializedIcon
|
|
8
8
|
readonly items?: readonly CiderpressSidebarItem[]
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface CiderpressSidebarLink {
|
|
12
12
|
readonly text: string
|
|
13
13
|
readonly link: string
|
|
14
|
-
readonly icon?:
|
|
14
|
+
readonly icon?: SerializedIcon
|
|
15
15
|
readonly style?: 'brand' | 'alt' | 'ghost'
|
|
16
16
|
readonly shape?: 'square' | 'rounded' | 'circle'
|
|
17
17
|
}
|
|
@@ -19,7 +19,7 @@ export interface CiderpressSidebarLink {
|
|
|
19
19
|
export interface WorkspaceCardData {
|
|
20
20
|
readonly title: string
|
|
21
21
|
readonly href: string
|
|
22
|
-
readonly icon:
|
|
22
|
+
readonly icon: SerializedIcon | undefined
|
|
23
23
|
readonly scope: string | undefined
|
|
24
24
|
readonly description: string | undefined
|
|
25
25
|
readonly tags: readonly string[]
|
|
@@ -33,6 +33,61 @@ export interface WorkspaceGroupData {
|
|
|
33
33
|
readonly cards: readonly WorkspaceCardData[]
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Serialised view of the unified `CiderpressConfig` that the runtime
|
|
38
|
+
* theme components still read through. The `site` field is rebuilt in
|
|
39
|
+
* `packages/ui/src/config.ts` (`buildSiteBlock`) from the new top-level
|
|
40
|
+
* `editLink` / `reportLink` / `topbar` / `sidebar` / `footer` / `version`
|
|
41
|
+
* config — kept under the legacy `site.*` name so theme components don't
|
|
42
|
+
* need to be rewired to look up each field individually.
|
|
43
|
+
*/
|
|
44
|
+
export interface CiderpressSiteBlock {
|
|
45
|
+
readonly version: string | undefined
|
|
46
|
+
readonly edit:
|
|
47
|
+
| {
|
|
48
|
+
readonly repo: string
|
|
49
|
+
readonly branch?: string
|
|
50
|
+
readonly directory?: string
|
|
51
|
+
readonly label?: string
|
|
52
|
+
}
|
|
53
|
+
| undefined
|
|
54
|
+
readonly report:
|
|
55
|
+
| {
|
|
56
|
+
readonly repo: string
|
|
57
|
+
readonly branch?: string
|
|
58
|
+
readonly directory?: string
|
|
59
|
+
readonly label?: string
|
|
60
|
+
}
|
|
61
|
+
| undefined
|
|
62
|
+
readonly topbarCta: { readonly text: string; readonly href: string } | undefined
|
|
63
|
+
readonly sidebarPromo:
|
|
64
|
+
| {
|
|
65
|
+
readonly title: string
|
|
66
|
+
readonly body: string
|
|
67
|
+
readonly cta: { readonly text: string; readonly href: string }
|
|
68
|
+
}
|
|
69
|
+
| undefined
|
|
70
|
+
readonly announcement:
|
|
71
|
+
| {
|
|
72
|
+
readonly id?: string
|
|
73
|
+
readonly lead?: string
|
|
74
|
+
readonly message: string
|
|
75
|
+
readonly cta?: { readonly href: string; readonly label: string }
|
|
76
|
+
readonly persistent?: boolean
|
|
77
|
+
}
|
|
78
|
+
| undefined
|
|
79
|
+
readonly footer:
|
|
80
|
+
| {
|
|
81
|
+
readonly columns?: readonly {
|
|
82
|
+
readonly heading: string
|
|
83
|
+
readonly links: readonly { readonly text: string; readonly href: string }[]
|
|
84
|
+
}[]
|
|
85
|
+
readonly tagline?: string
|
|
86
|
+
readonly brandMark?: string
|
|
87
|
+
}
|
|
88
|
+
| undefined
|
|
89
|
+
}
|
|
90
|
+
|
|
36
91
|
interface CiderpressThemeConfig {
|
|
37
92
|
readonly sidebar: Record<string, readonly CiderpressSidebarItem[]>
|
|
38
93
|
readonly sidebarAbove: readonly CiderpressSidebarLink[] | undefined
|
|
@@ -41,7 +96,7 @@ interface CiderpressThemeConfig {
|
|
|
41
96
|
readonly standaloneScopePaths: readonly string[] | undefined
|
|
42
97
|
readonly home: HomeConfig | undefined
|
|
43
98
|
readonly ciderpressFooter: FooterConfig | undefined
|
|
44
|
-
readonly site:
|
|
99
|
+
readonly site: CiderpressSiteBlock | undefined
|
|
45
100
|
}
|
|
46
101
|
|
|
47
102
|
/**
|
|
@@ -2,8 +2,9 @@ import type { CiderpressSocialLink } from '../components/nav/ciderpress-nav-soci
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Pull social-link entries (GitHub, npm, etc) from Rspress's `site`
|
|
5
|
-
* shape. Lives on `site.themeConfig.socialLinks` after
|
|
6
|
-
*
|
|
5
|
+
* shape. Lives on `site.themeConfig.socialLinks` after the
|
|
6
|
+
* `packages/ui/src/config.ts` serialiser writes the unified `socials`
|
|
7
|
+
* config into the runtime theme config.
|
|
7
8
|
*
|
|
8
9
|
* @param site - Rspress site data (typically the result of `useSite().site`)
|
|
9
10
|
* @returns Array of social-link entries (empty array when not configured)
|
|
@@ -22,6 +23,6 @@ export function readSocialLinks(site: unknown): readonly CiderpressSocialLink[]
|
|
|
22
23
|
typeof item === 'object' &&
|
|
23
24
|
item !== null &&
|
|
24
25
|
typeof (item as { icon?: unknown }).icon === 'string' &&
|
|
25
|
-
typeof (item as {
|
|
26
|
+
typeof (item as { url?: unknown }).url === 'string'
|
|
26
27
|
)
|
|
27
28
|
}
|
|
@@ -107,7 +107,7 @@ function buildIconDataUri(brand: string, shadow: string, surface: string): strin
|
|
|
107
107
|
/**
|
|
108
108
|
* Locate the existing `<link rel="icon">` element, creating one if the
|
|
109
109
|
* document head doesn't have one yet (a defensive fallback — Rspress
|
|
110
|
-
* normally renders one from `
|
|
110
|
+
* normally renders one from `brand.favicon`).
|
|
111
111
|
*
|
|
112
112
|
* @private
|
|
113
113
|
* @returns Mutable link element
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { withBase } from '@rspress/core/runtime'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Prefix `value` with the configured Rspress `base` only when it's an
|
|
5
|
+
* absolute path that would otherwise escape the mount. Pass-through for
|
|
6
|
+
* data URIs, fully-qualified URLs, hash anchors, and relative paths —
|
|
7
|
+
* applying `withBase()` to those produces broken results (the kitchen-
|
|
8
|
+
* sink data-URI logo regression that the examples e2e caught).
|
|
9
|
+
*
|
|
10
|
+
* Use this wrapper at every render site that takes a user-supplied asset
|
|
11
|
+
* URL from the ciderpress config (`logo`, `heroDemo.src`, brand chips
|
|
12
|
+
* etc.), instead of calling `withBase()` directly.
|
|
13
|
+
*
|
|
14
|
+
* @param value - Asset URL or path from user config (may be `undefined`)
|
|
15
|
+
* @returns The base-prefixed URL when applicable, otherwise `value` as-is
|
|
16
|
+
*/
|
|
17
|
+
export function withMountBase(value: string | undefined): string {
|
|
18
|
+
if (value === undefined) {
|
|
19
|
+
return ''
|
|
20
|
+
}
|
|
21
|
+
if (!value.startsWith('/')) {
|
|
22
|
+
return value
|
|
23
|
+
}
|
|
24
|
+
// Data URIs (`data:image/svg+xml;...`) and protocol-relative or
|
|
25
|
+
// explicit-protocol URLs are absolute in their own namespace — never
|
|
26
|
+
// prefix.
|
|
27
|
+
if (value.startsWith('//') || /^[a-z][a-z0-9+\-.]*:/i.test(value)) {
|
|
28
|
+
return value
|
|
29
|
+
}
|
|
30
|
+
return withBase(value)
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ciderpress/ui",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.5",
|
|
4
4
|
"description": "Rspress plugin, theme components, and styles for ciderpress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ciderpress",
|
|
@@ -48,31 +48,31 @@
|
|
|
48
48
|
"@iconify-json/catppuccin": "^1.2.17",
|
|
49
49
|
"@iconify-json/devicon": "^1.2.62",
|
|
50
50
|
"@iconify-json/logos": "^1.2.11",
|
|
51
|
-
"@iconify-json/material-icon-theme": "^1.2.
|
|
51
|
+
"@iconify-json/material-icon-theme": "^1.2.68",
|
|
52
52
|
"@iconify-json/mdi": "^1.2.3",
|
|
53
53
|
"@iconify-json/pixelarticons": "^1.2.6",
|
|
54
|
-
"@iconify-json/simple-icons": "^1.2.
|
|
54
|
+
"@iconify-json/simple-icons": "^1.2.87",
|
|
55
55
|
"@iconify-json/skill-icons": "^1.2.4",
|
|
56
|
-
"@iconify-json/vscode-icons": "^1.2.
|
|
56
|
+
"@iconify-json/vscode-icons": "^1.2.62",
|
|
57
57
|
"@iconify/react": "^6.0.2",
|
|
58
58
|
"clsx": "^2.1.1",
|
|
59
59
|
"katex": "^0.17.0",
|
|
60
|
-
"massaman": "^0.
|
|
60
|
+
"massaman": "^0.3.0",
|
|
61
61
|
"mermaid": "^10.9.6",
|
|
62
62
|
"openapi-sampler": "^1.7.4",
|
|
63
|
-
"react-aria-components": "^1.
|
|
63
|
+
"react-aria-components": "^1.19.0",
|
|
64
64
|
"ts-morph": "^28.0.0",
|
|
65
65
|
"unist-util-visit": "^5.1.0",
|
|
66
|
-
"@ciderpress/config": "1.0.0-rc.
|
|
67
|
-
"@ciderpress/theme": "1.0.0-rc.
|
|
66
|
+
"@ciderpress/config": "1.0.0-rc.4",
|
|
67
|
+
"@ciderpress/theme": "1.0.0-rc.3"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@ladle/react": "^5.1.1",
|
|
71
|
-
"@rslib/core": "^0.
|
|
72
|
-
"@rspress/core": "^2.0.
|
|
71
|
+
"@rslib/core": "^0.23.1",
|
|
72
|
+
"@rspress/core": "^2.0.15",
|
|
73
73
|
"@types/react": "^19.2.17",
|
|
74
74
|
"@types/react-dom": "^19.2.3",
|
|
75
|
-
"esbuild": "^0.28.
|
|
75
|
+
"esbuild": "^0.28.1",
|
|
76
76
|
"geist": "^1.7.2",
|
|
77
77
|
"react": "^19.2.7",
|
|
78
78
|
"react-dom": "^19.2.7",
|
|
@@ -81,10 +81,10 @@
|
|
|
81
81
|
"rspress-plugin-katex": "^1.0.1",
|
|
82
82
|
"rspress-plugin-supersub": "^1.0.0",
|
|
83
83
|
"typescript": "^6.0.3",
|
|
84
|
-
"vitest": "^4.1.
|
|
84
|
+
"vitest": "^4.1.9"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
|
-
"@rspress/core": "^2.0.
|
|
87
|
+
"@rspress/core": "^2.0.15",
|
|
88
88
|
"react": "^19.2.5",
|
|
89
89
|
"react-dom": "^19.2.5"
|
|
90
90
|
},
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import type { CopyrightConfig, FooterConfig } from '@ciderpress/config'
|
|
1
2
|
import { useSite } from '@rspress/core/runtime'
|
|
2
|
-
import { match } from 'massaman/match'
|
|
3
|
+
import { match, P } from 'massaman/match'
|
|
3
4
|
import type React from 'react'
|
|
4
5
|
|
|
5
6
|
import { useCiderpress } from '../../hooks/use-ciderpress'
|
|
6
7
|
import { readSocialLinks } from '../../lib/read-social-links'
|
|
7
8
|
import { RouteLink } from '../../lib/route-link.tsx'
|
|
8
9
|
import { safeUrl } from '../../lib/safe-url.ts'
|
|
10
|
+
import { withMountBase } from '../../lib/with-mount-base.ts'
|
|
9
11
|
import { CiderpressNavSocialLinks } from '../nav/ciderpress-nav-social-links'
|
|
10
12
|
import { ThemeSwitcher } from '../nav/theme-switcher'
|
|
11
|
-
import { CiderpressMark } from '../shared/ciderpress-mark'
|
|
12
13
|
|
|
13
14
|
import './site-footer.css'
|
|
14
15
|
|
|
@@ -35,14 +36,17 @@ export function SiteFooter(): React.ReactElement | null {
|
|
|
35
36
|
const { message, copyright, socials } = ciderpressFooter ?? {}
|
|
36
37
|
const { columns, tagline, brandMark } = siteFooter ?? {}
|
|
37
38
|
|
|
38
|
-
const
|
|
39
|
+
const copyrightText = resolveCopyright(copyright, rspressSite.title)
|
|
40
|
+
const shouldRenderSocials = socials === true && socialLinks.length > 0
|
|
41
|
+
|
|
42
|
+
const hasFooterContent = message !== undefined || copyrightText !== null || shouldRenderSocials
|
|
39
43
|
const hasSiteContent = columns !== undefined || tagline !== undefined
|
|
40
44
|
// The footer also hosts the theme switcher when it's enabled — so a
|
|
41
|
-
// config with `theme.
|
|
45
|
+
// config with `theme.themeSwitcher: true` but no other footer content
|
|
42
46
|
// still needs the footer shell rendered.
|
|
43
47
|
const hasSwitcher = __CIDERPRESS_THEME_SWITCHER__
|
|
44
48
|
|
|
45
|
-
if (!
|
|
49
|
+
if (!hasFooterContent && !hasSiteContent && !hasSwitcher) {
|
|
46
50
|
return null
|
|
47
51
|
}
|
|
48
52
|
|
|
@@ -56,7 +60,16 @@ export function SiteFooter(): React.ReactElement | null {
|
|
|
56
60
|
<div className="cp-site-footer__brand-mark">
|
|
57
61
|
{match(brandMark)
|
|
58
62
|
.with(undefined, () => (
|
|
59
|
-
|
|
63
|
+
// Default to the project's `/icon.svg` (auto-generated
|
|
64
|
+
// from `config.title` at sync time, or overridden by
|
|
65
|
+
// shipping a `public/icon.svg`). This was previously
|
|
66
|
+
// the hardcoded `<CiderpressMark />` apple, which
|
|
67
|
+
// leaked ciderpress branding into every footer.
|
|
68
|
+
<img
|
|
69
|
+
src={withMountBase('/icon.svg')}
|
|
70
|
+
alt=""
|
|
71
|
+
className="cp-site-footer__brand-icon"
|
|
72
|
+
/>
|
|
60
73
|
))
|
|
61
74
|
.otherwise((mark) => mark)}
|
|
62
75
|
</div>
|
|
@@ -65,7 +78,7 @@ export function SiteFooter(): React.ReactElement | null {
|
|
|
65
78
|
.otherwise((msg) => (
|
|
66
79
|
<p className="cp-site-footer__message">{msg}</p>
|
|
67
80
|
))}
|
|
68
|
-
{match(
|
|
81
|
+
{match(shouldRenderSocials)
|
|
69
82
|
.with(true, () => (
|
|
70
83
|
<div className="cp-site-footer__socials">
|
|
71
84
|
<CiderpressNavSocialLinks links={socialLinks} />
|
|
@@ -95,8 +108,8 @@ export function SiteFooter(): React.ReactElement | null {
|
|
|
95
108
|
</div>
|
|
96
109
|
<div className="cp-site-footer__bottom">
|
|
97
110
|
<div className="cp-site-footer__bottom-inner">
|
|
98
|
-
{match(
|
|
99
|
-
.with(
|
|
111
|
+
{match(copyrightText)
|
|
112
|
+
.with(null, () => null)
|
|
100
113
|
.otherwise((cr) => (
|
|
101
114
|
<span className="cp-site-footer__copyright">{cr}</span>
|
|
102
115
|
))}
|
|
@@ -113,3 +126,49 @@ export function SiteFooter(): React.ReactElement | null {
|
|
|
113
126
|
</footer>
|
|
114
127
|
)
|
|
115
128
|
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Resolve the `footer.copyright` config union into a string for rendering.
|
|
132
|
+
*
|
|
133
|
+
* Accepts the new public shape: `true` for auto-generation from the site
|
|
134
|
+
* title + current year, a verbatim string, or a `CopyrightConfig` object
|
|
135
|
+
* with `company` / `dba` / `year`. `undefined` returns `null` so the
|
|
136
|
+
* caller can skip the render.
|
|
137
|
+
*
|
|
138
|
+
* @private
|
|
139
|
+
* @param copyright - The footer copyright config value
|
|
140
|
+
* @param siteTitle - The Rspress site title to use as fallback owner name
|
|
141
|
+
* @returns The formatted copyright string, or `null` when nothing should render
|
|
142
|
+
*/
|
|
143
|
+
function resolveCopyright(
|
|
144
|
+
copyright: FooterConfig['copyright'],
|
|
145
|
+
siteTitle: string | undefined
|
|
146
|
+
): string | null {
|
|
147
|
+
return match(copyright)
|
|
148
|
+
.with(undefined, () => null)
|
|
149
|
+
.with(true, () => formatCopyright({}, siteTitle))
|
|
150
|
+
.with(P.string, (s) => s)
|
|
151
|
+
.otherwise((cfg) => formatCopyright(cfg, siteTitle))
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Build a copyright string from a partial `CopyrightConfig`. Falls back to
|
|
156
|
+
* the site title for the owner name and the current year for the date.
|
|
157
|
+
*
|
|
158
|
+
* @private
|
|
159
|
+
* @param cfg - Copyright config object (may be empty)
|
|
160
|
+
* @param siteTitle - Fallback owner name
|
|
161
|
+
* @returns Formatted copyright string
|
|
162
|
+
*/
|
|
163
|
+
function formatCopyright(cfg: CopyrightConfig, siteTitle: string | undefined): string {
|
|
164
|
+
const currentYear = new Date().getFullYear()
|
|
165
|
+
const yearPart = match(cfg.year)
|
|
166
|
+
.with(undefined, () => String(currentYear))
|
|
167
|
+
.with(P.number, (n) => String(n))
|
|
168
|
+
.otherwise(({ from }) => `${from}–${currentYear}`)
|
|
169
|
+
const owner = cfg.dba ?? cfg.company ?? siteTitle ?? ''
|
|
170
|
+
const ownerPart = match(owner.length === 0)
|
|
171
|
+
.with(true, () => '')
|
|
172
|
+
.otherwise(() => ` ${owner}`)
|
|
173
|
+
return `© ${yearPart}${ownerPart}`
|
|
174
|
+
}
|
|
@@ -3,14 +3,15 @@ import type React from 'react'
|
|
|
3
3
|
|
|
4
4
|
import './feature-card.css'
|
|
5
5
|
import { Card } from '../shared/card'
|
|
6
|
-
import {
|
|
6
|
+
import { CardIcon } from '../shared/card-icon'
|
|
7
|
+
import type { CardIconInput } from '../shared/resolve-card-icon'
|
|
7
8
|
import { resolveCardIcon } from '../shared/resolve-card-icon'
|
|
8
9
|
|
|
9
10
|
export interface FeatureCardProps {
|
|
10
11
|
readonly title: string
|
|
11
12
|
readonly description: string
|
|
12
13
|
readonly href?: string
|
|
13
|
-
readonly icon?:
|
|
14
|
+
readonly icon?: CardIconInput
|
|
14
15
|
readonly span?: 2 | 3 | 4 | 6
|
|
15
16
|
readonly titleLines?: number
|
|
16
17
|
readonly descriptionLines?: number
|
|
@@ -23,7 +24,7 @@ export interface FeatureItem {
|
|
|
23
24
|
readonly title: string
|
|
24
25
|
readonly details: string
|
|
25
26
|
readonly link?: string
|
|
26
|
-
readonly icon?:
|
|
27
|
+
readonly icon?: CardIconInput
|
|
27
28
|
readonly span?: 2 | 3 | 4 | 6
|
|
28
29
|
}
|
|
29
30
|
|
|
@@ -46,11 +47,7 @@ export function FeatureCard({
|
|
|
46
47
|
const resolved = resolveCardIcon(icon)
|
|
47
48
|
|
|
48
49
|
const iconEl = match(resolved)
|
|
49
|
-
.with(P.nonNullable, (r) =>
|
|
50
|
-
<span className={`cp-card__icon cp-card__icon--${r.color}`}>
|
|
51
|
-
<Icon icon={r.id} />
|
|
52
|
-
</span>
|
|
53
|
-
))
|
|
50
|
+
.with(P.nonNullable, (r) => <CardIcon resolved={r} className="cp-card__icon" />)
|
|
54
51
|
.otherwise(() => null)
|
|
55
52
|
|
|
56
53
|
const linkTail = match(href)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HomeFeaturesConfig } from '@ciderpress/config'
|
|
2
2
|
import { useFrontmatter } from '@rspress/core/runtime'
|
|
3
3
|
import { match, P } from 'massaman/match'
|
|
4
4
|
import type React from 'react'
|
|
@@ -7,6 +7,17 @@ import { useCiderpress } from '../../hooks/use-ciderpress'
|
|
|
7
7
|
import { FeatureCard } from './feature-card'
|
|
8
8
|
import type { FeatureItem } from './feature-card'
|
|
9
9
|
|
|
10
|
+
interface FrontmatterFeaturesHeading {
|
|
11
|
+
readonly label?: string
|
|
12
|
+
readonly title?: string
|
|
13
|
+
readonly subtitle?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const DEFAULT_HEADING_EYEBROW = 'Features'
|
|
17
|
+
const DEFAULT_HEADING_TITLE = 'Built for the way you ship.'
|
|
18
|
+
const DEFAULT_HEADING_SUBTITLE =
|
|
19
|
+
"Everything you need, nothing you don't. Configured in TypeScript, validated at boot."
|
|
20
|
+
|
|
10
21
|
/**
|
|
11
22
|
* Custom HomeFeature override for ciderpress.
|
|
12
23
|
* Uses useFrontmatter() hook to read features and renders with FeatureCard/FeatureGrid styling.
|
|
@@ -21,9 +32,21 @@ export function HomeFeature(): React.ReactElement | null {
|
|
|
21
32
|
// Rspress types frontmatter as its own FrontMatterMeta shape which does not
|
|
22
33
|
// include ciderpress-specific `features`. The double cast is necessary because
|
|
23
34
|
// no shared Zod schema exists for frontmatter validation at runtime.
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
35
|
+
const fm = frontmatter as Record<string, unknown>
|
|
36
|
+
const features = fm.features as readonly FeatureItem[] | undefined
|
|
37
|
+
const heading = fm.featuresHeading as FrontmatterFeaturesHeading | undefined
|
|
38
|
+
// Frontmatter is unvalidated user content — a `featuresHeading.title: {}`
|
|
39
|
+
// would otherwise render as `[object Object]` in the H2. Treat any
|
|
40
|
+
// non-string value as missing and fall through to the framework default.
|
|
41
|
+
const headingEyebrow = match(heading && heading.label)
|
|
42
|
+
.with(P.string, (s) => s)
|
|
43
|
+
.otherwise(() => DEFAULT_HEADING_EYEBROW)
|
|
44
|
+
const headingTitle = match(heading && heading.title)
|
|
45
|
+
.with(P.string, (s) => s)
|
|
46
|
+
.otherwise(() => DEFAULT_HEADING_TITLE)
|
|
47
|
+
const headingSubtitle = match(heading && heading.subtitle)
|
|
48
|
+
.with(P.string, (s) => s)
|
|
49
|
+
.otherwise(() => DEFAULT_HEADING_SUBTITLE)
|
|
27
50
|
|
|
28
51
|
return match(features)
|
|
29
52
|
.with(
|
|
@@ -31,12 +54,9 @@ export function HomeFeature(): React.ReactElement | null {
|
|
|
31
54
|
(items) => (
|
|
32
55
|
<div className="cp-feature-section">
|
|
33
56
|
<div className="cp-feature-section-head">
|
|
34
|
-
<div className="cp-feature-section-head__eyebrow">
|
|
35
|
-
<h2 className="cp-feature-section-head__title">
|
|
36
|
-
<p className="cp-feature-section-head__sub">
|
|
37
|
-
Everything you need, nothing you don't. Configured in TypeScript, validated at
|
|
38
|
-
boot.
|
|
39
|
-
</p>
|
|
57
|
+
<div className="cp-feature-section-head__eyebrow">{headingEyebrow}</div>
|
|
58
|
+
<h2 className="cp-feature-section-head__title">{headingTitle}</h2>
|
|
59
|
+
<p className="cp-feature-section-head__sub">{headingSubtitle}</p>
|
|
40
60
|
</div>
|
|
41
61
|
<div className="cp-feature-grid">
|
|
42
62
|
{items.map((f, i) => renderFeature(f, i, gridConfig))}
|
|
@@ -60,7 +80,7 @@ export function HomeFeature(): React.ReactElement | null {
|
|
|
60
80
|
function renderFeature(
|
|
61
81
|
feature: FeatureItem,
|
|
62
82
|
index: number,
|
|
63
|
-
gridConfig:
|
|
83
|
+
gridConfig: HomeFeaturesConfig | undefined
|
|
64
84
|
): React.ReactElement {
|
|
65
85
|
const titleLines = gridConfig && gridConfig.truncate && gridConfig.truncate.title
|
|
66
86
|
const descLines = gridConfig && gridConfig.truncate && gridConfig.truncate.description
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { HomeHeroDemoConfig, HomeHeroDemoLine, HomeHeroDemoTerminal } from '@ciderpress/config'
|
|
2
|
+
import { match } from 'massaman/match'
|
|
3
|
+
import type React from 'react'
|
|
4
|
+
|
|
5
|
+
import { withMountBase } from '../../lib/with-mount-base.ts'
|
|
6
|
+
|
|
7
|
+
import './hero-demo.css'
|
|
8
|
+
|
|
9
|
+
interface CustomHeroDemoProps {
|
|
10
|
+
readonly config: HomeHeroDemoConfig
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Custom replacement for `<HeroDemo />`. Driven by `home.hero.demo` from
|
|
15
|
+
* `ciderpress.config.ts`:
|
|
16
|
+
*
|
|
17
|
+
* - **Image form** (`{ src, alt, width?, height? }`) — renders an
|
|
18
|
+
* `<img>` inside the framework's framed `cp-hero-demo` container
|
|
19
|
+
* (rounded corners + brand-soft glow shadow preserved).
|
|
20
|
+
* - **Terminal form** (`{ windowTitle?, command, lines }`) — keeps the
|
|
21
|
+
* fake-macOS chrome but paints the user's command + output lines.
|
|
22
|
+
*
|
|
23
|
+
* The discriminator is structural: image objects carry `src`, terminal
|
|
24
|
+
* objects carry `lines`.
|
|
25
|
+
*
|
|
26
|
+
* @param props - Validated `HomeHeroDemoConfig`
|
|
27
|
+
* @returns Custom hero demo element
|
|
28
|
+
*/
|
|
29
|
+
export function CustomHeroDemo(props: CustomHeroDemoProps): React.ReactElement {
|
|
30
|
+
return match(props.config)
|
|
31
|
+
.when(
|
|
32
|
+
(c): c is HomeHeroDemoTerminal => 'lines' in c,
|
|
33
|
+
(c) => <CustomTerminal config={c} />
|
|
34
|
+
)
|
|
35
|
+
.otherwise((c) => (
|
|
36
|
+
<div className="cp-hero-demo cp-hero-demo--image">
|
|
37
|
+
<img
|
|
38
|
+
src={withMountBase(c.src)}
|
|
39
|
+
alt={c.alt ?? ''}
|
|
40
|
+
width={c.width}
|
|
41
|
+
height={c.height}
|
|
42
|
+
className="cp-hero-demo__img"
|
|
43
|
+
/>
|
|
44
|
+
</div>
|
|
45
|
+
))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface CustomTerminalProps {
|
|
49
|
+
readonly config: HomeHeroDemoTerminal
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Render the terminal-form hero demo with user-supplied command + lines.
|
|
54
|
+
*
|
|
55
|
+
* @private
|
|
56
|
+
* @param props - Validated terminal config
|
|
57
|
+
* @returns Terminal-shell hero demo element
|
|
58
|
+
*/
|
|
59
|
+
function CustomTerminal(props: CustomTerminalProps): React.ReactElement {
|
|
60
|
+
const { windowTitle, command, lines } = props.config
|
|
61
|
+
return (
|
|
62
|
+
<div className="cp-hero-demo">
|
|
63
|
+
<div className="cp-hero-demo__bar">
|
|
64
|
+
<span className="cp-hero-demo__dot" />
|
|
65
|
+
<span className="cp-hero-demo__dot" />
|
|
66
|
+
<span className="cp-hero-demo__dot" />
|
|
67
|
+
{match(windowTitle)
|
|
68
|
+
.with(undefined, () => null)
|
|
69
|
+
.otherwise((t) => (
|
|
70
|
+
<span className="cp-hero-demo__title">{t}</span>
|
|
71
|
+
))}
|
|
72
|
+
</div>
|
|
73
|
+
<pre className="cp-hero-demo__body">
|
|
74
|
+
<span className="cp-hero-demo__prompt">$ </span>
|
|
75
|
+
{command}
|
|
76
|
+
{'\n\n'}
|
|
77
|
+
{lines.map((line, i) => (
|
|
78
|
+
<TerminalLine key={`${line.kind}-${i}`} line={line} />
|
|
79
|
+
))}
|
|
80
|
+
</pre>
|
|
81
|
+
</div>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
interface TerminalLineProps {
|
|
86
|
+
readonly line: HomeHeroDemoLine
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Render a single line of the structured terminal hero demo. Each
|
|
91
|
+
* kind gets a coloured prefix glyph mirroring the framework default.
|
|
92
|
+
*
|
|
93
|
+
* @private
|
|
94
|
+
* @param props - Single line entry
|
|
95
|
+
* @returns Glyph-prefixed line followed by a newline
|
|
96
|
+
*/
|
|
97
|
+
function TerminalLine(props: TerminalLineProps): React.ReactElement {
|
|
98
|
+
const className = match(props.line.kind)
|
|
99
|
+
.with('ok', () => 'cp-hero-demo__ok')
|
|
100
|
+
.with('info', () => 'cp-hero-demo__info')
|
|
101
|
+
.with('cmt', () => 'cp-hero-demo__cmt')
|
|
102
|
+
.with('err', () => 'cp-hero-demo__err')
|
|
103
|
+
.exhaustive()
|
|
104
|
+
const glyph = match(props.line.kind)
|
|
105
|
+
.with('ok', () => ' ✓')
|
|
106
|
+
.with('info', () => ' ▸')
|
|
107
|
+
.with('cmt', () => ' ↻')
|
|
108
|
+
.with('err', () => ' ✗')
|
|
109
|
+
.exhaustive()
|
|
110
|
+
return (
|
|
111
|
+
<>
|
|
112
|
+
<span className={className}>{glyph}</span> {props.line.text}
|
|
113
|
+
{'\n'}
|
|
114
|
+
</>
|
|
115
|
+
)
|
|
116
|
+
}
|
|
@@ -64,3 +64,30 @@
|
|
|
64
64
|
.cp-hero-demo__file {
|
|
65
65
|
color: var(--cp-c-tint-amber-bright-fg);
|
|
66
66
|
}
|
|
67
|
+
|
|
68
|
+
/* Image-form hero demo — the frame chrome (rounded corners + brand-soft
|
|
69
|
+
glow shadow) stays; the `<img>` simply fills the surface. The hero
|
|
70
|
+
slot already constrains aspect ratio. */
|
|
71
|
+
.cp-hero-demo--image {
|
|
72
|
+
padding: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.cp-hero-demo__img {
|
|
76
|
+
display: block;
|
|
77
|
+
width: 100%;
|
|
78
|
+
height: auto;
|
|
79
|
+
border-radius: inherit;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* Custom Split visual `<pre>` shares the `.cp-split__code` surface with
|
|
83
|
+
the default `ConfigPreview` block — same padding, font, scrolling. */
|
|
84
|
+
.cp-split__code {
|
|
85
|
+
margin: 0;
|
|
86
|
+
padding: var(--cp-s-20) var(--cp-s-24);
|
|
87
|
+
font-family: var(--cp-font-family-mono);
|
|
88
|
+
font-size: var(--cp-fs-code);
|
|
89
|
+
line-height: var(--cp-lh-code);
|
|
90
|
+
white-space: pre;
|
|
91
|
+
overflow-x: auto;
|
|
92
|
+
color: var(--cp-c-text-1);
|
|
93
|
+
}
|