react-cheminfo 0.19.0 → 0.21.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/lib/about/core/about.d.ts +9 -7
- package/lib/about/core/about.d.ts.map +1 -1
- package/lib/about/core/about.js +8 -2
- package/lib/about/core/about.js.map +1 -1
- package/lib/about/ui/AboutPage.d.ts.map +1 -1
- package/lib/about/ui/AboutPage.js +1 -1
- package/lib/about/ui/AboutPage.js.map +1 -1
- package/lib/about/ui/AboutVersion.d.ts +7 -6
- package/lib/about/ui/AboutVersion.d.ts.map +1 -1
- package/lib/about/ui/AboutVersion.js +32 -9
- package/lib/about/ui/AboutVersion.js.map +1 -1
- package/lib/build/core/buildInfo.d.ts +28 -0
- package/lib/build/core/buildInfo.d.ts.map +1 -1
- package/lib/build/core/buildInfo.js +42 -0
- package/lib/build/core/buildInfo.js.map +1 -1
- package/lib/build/core/index.d.ts +1 -1
- package/lib/build/core/index.d.ts.map +1 -1
- package/lib/build/core/index.js +1 -1
- package/lib/build/core/index.js.map +1 -1
- package/lib/chrome/ui/SiteHeader.d.ts +20 -3
- package/lib/chrome/ui/SiteHeader.d.ts.map +1 -1
- package/lib/chrome/ui/SiteHeader.js +7 -3
- package/lib/chrome/ui/SiteHeader.js.map +1 -1
- package/lib/ecosystem/core/index.d.ts +1 -1
- package/lib/ecosystem/core/index.d.ts.map +1 -1
- package/lib/ecosystem/core/index.js.map +1 -1
- package/lib/ecosystem/core/lookup.d.ts +2 -2
- package/lib/ecosystem/core/lookup.d.ts.map +1 -1
- package/lib/ecosystem/core/lookup.js.map +1 -1
- package/lib/ecosystem/core/nameColors.d.ts +2 -2
- package/lib/ecosystem/core/nameColors.d.ts.map +1 -1
- package/lib/ecosystem/core/nameColors.js.map +1 -1
- package/lib/ecosystem/core/sites.d.ts +3 -3
- package/lib/ecosystem/core/sites.d.ts.map +1 -1
- package/lib/ecosystem/core/sites.js.map +1 -1
- package/lib/ecosystem/core/tokens.d.ts +4 -3
- package/lib/ecosystem/core/tokens.d.ts.map +1 -1
- package/lib/ecosystem/core/tokens.js +8 -7
- package/lib/ecosystem/core/tokens.js.map +1 -1
- package/lib/ecosystem/core/types.d.ts +18 -9
- package/lib/ecosystem/core/types.d.ts.map +1 -1
- package/lib/ecosystem/ui/SiteTheme.d.ts +14 -3
- package/lib/ecosystem/ui/SiteTheme.d.ts.map +1 -1
- package/lib/ecosystem/ui/SiteTheme.js +6 -1
- package/lib/ecosystem/ui/SiteTheme.js.map +1 -1
- package/lib/ecosystem/ui/Wordmark.d.ts +2 -2
- package/lib/ecosystem/ui/Wordmark.d.ts.map +1 -1
- package/lib/ecosystem/ui/marks.d.ts +13 -4
- package/lib/ecosystem/ui/marks.d.ts.map +1 -1
- package/lib/ecosystem/ui/marks.js +11 -3
- package/lib/ecosystem/ui/marks.js.map +1 -1
- package/lib/seo/core/pageMeta.d.ts +2 -2
- package/lib/seo/core/pageMeta.d.ts.map +1 -1
- package/lib/seo/core/siteFiles.d.ts +3 -3
- package/lib/seo/core/siteFiles.d.ts.map +1 -1
- package/lib/seo/core/siteFiles.js.map +1 -1
- package/lib/seo/vite/ogCard.d.ts +9 -2
- package/lib/seo/vite/ogCard.d.ts.map +1 -1
- package/lib/seo/vite/ogCard.js +6 -1
- package/lib/seo/vite/ogCard.js.map +1 -1
- package/lib/seo/vite/prerender.d.ts +2 -2
- package/lib/seo/vite/prerender.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/about/core/about.ts +19 -10
- package/src/about/ui/AboutPage.tsx +12 -6
- package/src/about/ui/AboutVersion.tsx +43 -15
- package/src/build/core/buildInfo.ts +43 -0
- package/src/build/core/index.ts +3 -0
- package/src/chrome/ui/SiteHeader.tsx +28 -6
- package/src/ecosystem/core/index.ts +1 -0
- package/src/ecosystem/core/lookup.ts +2 -2
- package/src/ecosystem/core/nameColors.ts +2 -2
- package/src/ecosystem/core/sites.ts +3 -2
- package/src/ecosystem/core/tokens.ts +10 -9
- package/src/ecosystem/core/types.ts +19 -9
- package/src/ecosystem/ui/SiteTheme.tsx +19 -4
- package/src/ecosystem/ui/Wordmark.tsx +2 -2
- package/src/ecosystem/ui/marks.tsx +23 -5
- package/src/seo/core/noscript.ts +1 -1
- package/src/seo/core/pageMeta.ts +2 -2
- package/src/seo/core/siteFiles.ts +3 -3
- package/src/seo/vite/ogCard.ts +16 -3
- package/src/seo/vite/prerender.ts +2 -2
|
@@ -1,41 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Which
|
|
2
|
+
* Which build of a site a visitor has open, in the corner of its hero.
|
|
3
3
|
*
|
|
4
4
|
* A report of something going wrong is worth answering only when we know what
|
|
5
|
-
* was running, and
|
|
6
|
-
*
|
|
5
|
+
* was running, and that is the one thing an About page cannot say from a
|
|
6
|
+
* hand-written record. It sits at the top of the page rather than at the
|
|
7
7
|
* bottom because it is the one line a reader is asked to quote back.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { CSSProperties, ReactElement } from 'react';
|
|
11
11
|
|
|
12
12
|
import type { BuildInfo } from '../../build/core/buildInfo.ts';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
buildLabel,
|
|
15
|
+
buildStamp,
|
|
16
|
+
buildSummary,
|
|
17
|
+
releasedVersion,
|
|
18
|
+
} from '../../build/core/buildInfo.ts';
|
|
14
19
|
import { githubSources } from '../core/repository.ts';
|
|
15
20
|
|
|
16
21
|
export interface AboutVersionProps {
|
|
17
22
|
/** What the build published about itself, or `undefined` when it published none. */
|
|
18
23
|
build: BuildInfo | undefined;
|
|
19
|
-
/** Where the sources live, which is what the
|
|
24
|
+
/** Where the sources live, which is what the badge links into. */
|
|
20
25
|
repository: string;
|
|
21
26
|
/** Whether a visitor can open that repository, and so whether it is linked. */
|
|
22
27
|
publicRepository: boolean;
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
/**
|
|
26
|
-
* The
|
|
31
|
+
* The build badge: the release a site is serving, or the commit it was built
|
|
32
|
+
* from while it has no release yet, and when it was made.
|
|
27
33
|
* @param props - See {@link AboutVersionProps}.
|
|
28
|
-
* @returns The badge, or `null
|
|
34
|
+
* @returns The badge, or `null` when the build says nothing worth showing.
|
|
29
35
|
*/
|
|
30
36
|
export function AboutVersion(props: AboutVersionProps): ReactElement | null {
|
|
31
37
|
const { build, repository, publicRepository } = props;
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
-
const
|
|
35
|
-
|
|
38
|
+
const label = buildLabel(build);
|
|
39
|
+
if (build === undefined || label === undefined) return null;
|
|
40
|
+
const href = publicRepository ? addressOf(build, repository) : undefined;
|
|
41
|
+
const summary = buildSummary(build);
|
|
42
|
+
// The instant belongs on the badge rather than in its hover: a version
|
|
43
|
+
// nobody can date says nothing about how old the page they read is.
|
|
44
|
+
const badge = `${label} · ${buildStamp(build.builtAt)}`;
|
|
45
|
+
if (href === undefined) {
|
|
36
46
|
return (
|
|
37
|
-
<span style={BADGE_STYLE} className="about-version">
|
|
38
|
-
{
|
|
47
|
+
<span style={BADGE_STYLE} className="about-version" title={summary}>
|
|
48
|
+
{badge}
|
|
39
49
|
</span>
|
|
40
50
|
);
|
|
41
51
|
}
|
|
@@ -43,16 +53,34 @@ export function AboutVersion(props: AboutVersionProps): ReactElement | null {
|
|
|
43
53
|
return (
|
|
44
54
|
<a
|
|
45
55
|
className="about-version"
|
|
46
|
-
href={
|
|
56
|
+
href={href}
|
|
57
|
+
title={summary}
|
|
47
58
|
target="_blank"
|
|
48
59
|
rel="noopener noreferrer"
|
|
49
60
|
style={LINK_BADGE_STYLE}
|
|
50
61
|
>
|
|
51
|
-
{
|
|
62
|
+
{badge}
|
|
52
63
|
</a>
|
|
53
64
|
);
|
|
54
65
|
}
|
|
55
66
|
|
|
67
|
+
/**
|
|
68
|
+
* What the badge opens: the release it names, or the commit it was built from.
|
|
69
|
+
* @param build - What the build published about itself.
|
|
70
|
+
* @param repository - Where the sources live.
|
|
71
|
+
* @returns The address, or `undefined` when nothing inside the repository can
|
|
72
|
+
* be addressed.
|
|
73
|
+
*/
|
|
74
|
+
function addressOf(build: BuildInfo, repository: string): string | undefined {
|
|
75
|
+
const sources = githubSources(repository);
|
|
76
|
+
if (sources === undefined) return undefined;
|
|
77
|
+
const version = releasedVersion(build);
|
|
78
|
+
if (version !== undefined) return `${sources}/releases/tag/v${version}`;
|
|
79
|
+
return build.commit === undefined
|
|
80
|
+
? undefined
|
|
81
|
+
: `${sources}/commit/${build.commit}`;
|
|
82
|
+
}
|
|
83
|
+
|
|
56
84
|
const BADGE_STYLE = {
|
|
57
85
|
flex: '0 0 auto',
|
|
58
86
|
fontFamily: 'var(--font-mono, ui-monospace, monospace)',
|
|
@@ -49,6 +49,48 @@ export function releasedVersion(
|
|
|
49
49
|
return version;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* What the build is called on the page: the release when there is one, and the
|
|
54
|
+
* commit when there is not.
|
|
55
|
+
*
|
|
56
|
+
* A site that has never been released still has to be identifiable in a
|
|
57
|
+
* report, and `0.0.0` identifies nothing while the commit it was built from
|
|
58
|
+
* identifies exactly one build.
|
|
59
|
+
* @param build - What the build published about itself, or `undefined`.
|
|
60
|
+
* @returns The label, or `undefined` when the build published neither.
|
|
61
|
+
*/
|
|
62
|
+
export function buildLabel(build: BuildInfo | undefined): string | undefined {
|
|
63
|
+
const version = releasedVersion(build);
|
|
64
|
+
if (version !== undefined) return version;
|
|
65
|
+
const commit = build?.commit;
|
|
66
|
+
return commit === undefined ? undefined : shortCommit(commit);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* When the build was made, as it is read on the badge: the day and the minute.
|
|
71
|
+
*
|
|
72
|
+
* A build a reader is asked to quote is worth little without a date, and two
|
|
73
|
+
* builds of the same day are told apart by the minute. The seconds are left to
|
|
74
|
+
* the hover, where the whole record is.
|
|
75
|
+
* @param builtAt - The ISO instant the build wrote.
|
|
76
|
+
* @returns The instant, in UTC, e.g. `2026-09-16 09:41 UTC`.
|
|
77
|
+
*/
|
|
78
|
+
export function buildStamp(builtAt: string): string {
|
|
79
|
+
return `${builtAt.slice(0, MINUTE_LENGTH).replace('T', ' ')} UTC`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The whole record in one line, for the hover of a badge that shows one part
|
|
84
|
+
* of it.
|
|
85
|
+
* @param build - What the build published about itself.
|
|
86
|
+
* @returns e.g. `Built 2026-09-16 09:41:07 UTC from commit a1b2c3d`.
|
|
87
|
+
*/
|
|
88
|
+
export function buildSummary(build: BuildInfo): string {
|
|
89
|
+
const built = `Built ${formatBuiltAt(build.builtAt)}`;
|
|
90
|
+
if (build.commit === undefined) return built;
|
|
91
|
+
return `${built} from commit ${shortCommit(build.commit)}`;
|
|
92
|
+
}
|
|
93
|
+
|
|
52
94
|
/**
|
|
53
95
|
* The commit as it is written for a reader.
|
|
54
96
|
* @param commit - The full hash.
|
|
@@ -69,4 +111,5 @@ export function formatBuiltAt(builtAt: string): string {
|
|
|
69
111
|
}
|
|
70
112
|
|
|
71
113
|
const SHORT_COMMIT_LENGTH = 7;
|
|
114
|
+
const MINUTE_LENGTH = 16;
|
|
72
115
|
const SECOND_LENGTH = 19;
|
package/src/build/core/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ReactElement, ReactNode } from 'react';
|
|
|
2
2
|
import { Fragment } from 'react';
|
|
3
3
|
|
|
4
4
|
import { siteById } from '../../ecosystem/core/lookup.ts';
|
|
5
|
-
import type { SiteId } from '../../ecosystem/core/sites.ts';
|
|
5
|
+
import type { SiteId, SiteRecord } from '../../ecosystem/core/sites.ts';
|
|
6
6
|
import { Wordmark } from '../../ecosystem/ui/Wordmark.tsx';
|
|
7
7
|
import { SiteMark } from '../../ecosystem/ui/marks.tsx';
|
|
8
8
|
|
|
@@ -12,8 +12,24 @@ import type { NavItem } from './navItem.ts';
|
|
|
12
12
|
import { isModifiedClick } from './navItem.ts';
|
|
13
13
|
|
|
14
14
|
export interface SiteHeaderProps {
|
|
15
|
-
/**
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* The site the bar belongs to, which draws its mark and writes its name. One
|
|
17
|
+
* of `site` and `siteId` is required.
|
|
18
|
+
* @default undefined
|
|
19
|
+
*/
|
|
20
|
+
siteId?: SiteId;
|
|
21
|
+
/**
|
|
22
|
+
* The same site, passed rather than named — for a site that is deliberately
|
|
23
|
+
* not one of `ECOSYSTEM_SITES`, and so is linked from no other site's menu.
|
|
24
|
+
* @default undefined
|
|
25
|
+
*/
|
|
26
|
+
site?: SiteRecord;
|
|
27
|
+
/**
|
|
28
|
+
* The site's own mark, for a site the shared glyph set does not hold. It
|
|
29
|
+
* stands where `SiteMark` would, at the size the site draws it.
|
|
30
|
+
* @default undefined — the family's mark for that site
|
|
31
|
+
*/
|
|
32
|
+
mark?: ReactNode;
|
|
17
33
|
/** The pages, in the order the bar lists them. */
|
|
18
34
|
nav: readonly NavItem[];
|
|
19
35
|
/**
|
|
@@ -86,10 +102,13 @@ export interface SiteHeaderProps {
|
|
|
86
102
|
* @param props - The site, its pages, its utilities, and whether the page is
|
|
87
103
|
* framed in another site.
|
|
88
104
|
* @returns The bar, or nothing at all on an embedded page.
|
|
105
|
+
* @throws {Error} When neither `site` nor `siteId` is given.
|
|
89
106
|
*/
|
|
90
107
|
export function SiteHeader(props: SiteHeaderProps): ReactElement | null {
|
|
91
108
|
const {
|
|
92
109
|
siteId,
|
|
110
|
+
site: record,
|
|
111
|
+
mark,
|
|
93
112
|
nav,
|
|
94
113
|
activeId,
|
|
95
114
|
actions,
|
|
@@ -104,7 +123,10 @@ export function SiteHeader(props: SiteHeaderProps): ReactElement | null {
|
|
|
104
123
|
|
|
105
124
|
if (embedded) return null;
|
|
106
125
|
|
|
107
|
-
const site = siteById(siteId);
|
|
126
|
+
const site = record ?? (siteId === undefined ? undefined : siteById(siteId));
|
|
127
|
+
if (site === undefined) {
|
|
128
|
+
throw new Error('SiteHeader needs one of its `site` and `siteId` props');
|
|
129
|
+
}
|
|
108
130
|
|
|
109
131
|
return (
|
|
110
132
|
<header className="app-header no-print">
|
|
@@ -119,8 +141,8 @@ export function SiteHeader(props: SiteHeaderProps): ReactElement | null {
|
|
|
119
141
|
onHome();
|
|
120
142
|
}}
|
|
121
143
|
>
|
|
122
|
-
<SiteMark
|
|
123
|
-
<Wordmark
|
|
144
|
+
{mark ?? <SiteMark site={site} size={markSize} />}
|
|
145
|
+
<Wordmark site={site} />
|
|
124
146
|
</a>
|
|
125
147
|
<nav className="app-header-nav">
|
|
126
148
|
{nav.map((item) => (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SiteGroup, SiteGroupId } from './groups.ts';
|
|
2
2
|
import { SITE_GROUPS } from './groups.ts';
|
|
3
|
-
import type { EcosystemSite, SiteId } from './sites.ts';
|
|
3
|
+
import type { EcosystemSite, SiteId, SiteRecord } from './sites.ts';
|
|
4
4
|
import { ECOSYSTEM_SITES } from './sites.ts';
|
|
5
5
|
|
|
6
6
|
/** One topic and the sites written under it. */
|
|
@@ -62,7 +62,7 @@ export function siteById(id: SiteId): EcosystemSite {
|
|
|
62
62
|
* @param site - The site being named.
|
|
63
63
|
* @returns What the site is called, in one string.
|
|
64
64
|
*/
|
|
65
|
-
export function siteDisplayName(site:
|
|
65
|
+
export function siteDisplayName(site: SiteRecord): string {
|
|
66
66
|
return site.name.dot === true
|
|
67
67
|
? site.host
|
|
68
68
|
: `${site.name.lead}${site.name.alt}`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FAMILY_TOKEN_VALUES, TOKEN } from '../../tokens/core/familyTokens.ts';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { SiteRecord } from './types.ts';
|
|
4
4
|
|
|
5
5
|
/** The colour each half of a site's name is written in. */
|
|
6
6
|
export interface SiteNameColors {
|
|
@@ -35,7 +35,7 @@ export interface SiteNameColorsOptions {
|
|
|
35
35
|
* @returns The colour of each half, and of the dot between them.
|
|
36
36
|
*/
|
|
37
37
|
export function siteNameColors(
|
|
38
|
-
site:
|
|
38
|
+
site: SiteRecord,
|
|
39
39
|
options: SiteNameColorsOptions = {},
|
|
40
40
|
): SiteNameColors {
|
|
41
41
|
const literal = options.colors === 'literal';
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// tokens-ok: file — every site's two colours are declared here.
|
|
2
|
-
import type { EcosystemSite } from './types.ts';
|
|
2
|
+
import type { EcosystemSite, SiteRecord } from './types.ts';
|
|
3
3
|
|
|
4
4
|
export type {
|
|
5
5
|
EcosystemSite,
|
|
6
6
|
SiteId,
|
|
7
7
|
SiteMarkColors,
|
|
8
8
|
SiteName,
|
|
9
|
+
SiteRecord,
|
|
9
10
|
} from './types.ts';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -295,6 +296,6 @@ export const ECOSYSTEM_SITES: readonly EcosystemSite[] = [
|
|
|
295
296
|
* @param site - The site being linked to.
|
|
296
297
|
* @returns The URL to open.
|
|
297
298
|
*/
|
|
298
|
-
export function siteUrl(site:
|
|
299
|
+
export function siteUrl(site: SiteRecord): string {
|
|
299
300
|
return `https://${site.host}/`;
|
|
300
301
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// tokens-ok: file — the block a site renders is written here.
|
|
2
2
|
import { siteById } from './lookup.ts';
|
|
3
|
-
import type {
|
|
3
|
+
import type { SiteId, SiteRecord } from './sites.ts';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The custom properties a site of the family sets on `:root`: the two colours
|
|
@@ -9,21 +9,22 @@ import type { EcosystemSite, SiteId } from './sites.ts';
|
|
|
9
9
|
*
|
|
10
10
|
* It is a complete rule rather than a list of declarations, so it drops into a
|
|
11
11
|
* `<style>` of a prerendered page as it is.
|
|
12
|
-
* @param
|
|
12
|
+
* @param site - The site whose palette is wanted: its id, or the record of a
|
|
13
|
+
* site that is not one of the family.
|
|
13
14
|
* @returns The `:root` rule, ending in a newline.
|
|
14
15
|
*/
|
|
15
|
-
export function siteTokensCss(
|
|
16
|
-
const
|
|
17
|
-
const answering = answeringColor(
|
|
16
|
+
export function siteTokensCss(site: SiteId | SiteRecord): string {
|
|
17
|
+
const record = typeof site === 'string' ? siteById(site) : site;
|
|
18
|
+
const answering = answeringColor(record);
|
|
18
19
|
const declarations = [
|
|
19
|
-
`--brand: ${
|
|
20
|
+
`--brand: ${record.brand};`,
|
|
20
21
|
`--brand-alt: ${answering};`,
|
|
21
22
|
];
|
|
22
23
|
|
|
23
24
|
// The answering colour of several sites is a yellow or an amber that sits
|
|
24
25
|
// around 2:1 on white, so text set in it needs the darkened form instead.
|
|
25
|
-
if (
|
|
26
|
-
declarations.push(`--brand-alt-text: ${
|
|
26
|
+
if (record.brandAlt !== answering) {
|
|
27
|
+
declarations.push(`--brand-alt-text: ${record.brandAlt};`);
|
|
27
28
|
}
|
|
28
29
|
declarations.push('--accent: var(--brand);');
|
|
29
30
|
|
|
@@ -32,6 +33,6 @@ export function siteTokensCss(id: SiteId): string {
|
|
|
32
33
|
|
|
33
34
|
// The second colour as the site's mark draws it: on the accent element, unless
|
|
34
35
|
// the mark inverts the pair and gives the plate the answering colour instead.
|
|
35
|
-
function answeringColor(site:
|
|
36
|
+
function answeringColor(site: SiteRecord): string {
|
|
36
37
|
return site.mark.accent === site.brand ? site.mark.plate : site.mark.accent;
|
|
37
38
|
}
|
|
@@ -50,10 +50,14 @@ export interface SiteName {
|
|
|
50
50
|
ink?: 'lead' | 'alt';
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
/**
|
|
54
|
+
* What the chrome draws a site from: its name, address and two colours. A site
|
|
55
|
+
* that is deliberately not one of the family writes its own, and passes it
|
|
56
|
+
* wherever a family site passes its id.
|
|
57
|
+
*/
|
|
58
|
+
export interface SiteRecord {
|
|
59
|
+
/** The identifier the site is named by. */
|
|
60
|
+
id: string;
|
|
57
61
|
/** The name, split the way the site's own wordmark splits it. */
|
|
58
62
|
name: SiteName;
|
|
59
63
|
/** Where the site lives, written the way it is typed. */
|
|
@@ -70,11 +74,6 @@ export interface EcosystemSite {
|
|
|
70
74
|
publicRepository?: boolean;
|
|
71
75
|
/** One line on what the site does. */
|
|
72
76
|
tagline: string;
|
|
73
|
-
/**
|
|
74
|
-
* The topic the site is written under, which is what decides where it sits
|
|
75
|
-
* in the menu and in the footer.
|
|
76
|
-
*/
|
|
77
|
-
group: SiteGroupId;
|
|
78
77
|
/**
|
|
79
78
|
* The colour the name is written in — the first half, or the second when
|
|
80
79
|
* `name.ink` leaves the first in the family's ink.
|
|
@@ -90,6 +89,17 @@ export interface EcosystemSite {
|
|
|
90
89
|
mark: SiteMarkColors;
|
|
91
90
|
}
|
|
92
91
|
|
|
92
|
+
/** One site of the family: its record, and the topic it is listed under. */
|
|
93
|
+
export interface EcosystemSite extends SiteRecord {
|
|
94
|
+
/** The identifier every component and helper names the site by. */
|
|
95
|
+
id: SiteId;
|
|
96
|
+
/**
|
|
97
|
+
* The topic the site is written under, which is what decides where it sits
|
|
98
|
+
* in the menu and in the footer.
|
|
99
|
+
*/
|
|
100
|
+
group: SiteGroupId;
|
|
101
|
+
}
|
|
102
|
+
|
|
93
103
|
/** The colours a site's mark is drawn in. */
|
|
94
104
|
export interface SiteMarkColors {
|
|
95
105
|
/** The rounded square the mark is drawn on. */
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import type { ReactElement } from 'react';
|
|
2
2
|
|
|
3
|
-
import type { SiteId } from '../core/sites.ts';
|
|
3
|
+
import type { SiteId, SiteRecord } from '../core/sites.ts';
|
|
4
4
|
import { siteTokensCss } from '../core/tokens.ts';
|
|
5
5
|
|
|
6
6
|
/** What the site palette needs. */
|
|
7
7
|
export interface SiteThemeProps {
|
|
8
|
-
/**
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* The site whose palette the page takes, named. One of `site` and `siteId`
|
|
10
|
+
* is required.
|
|
11
|
+
* @default undefined
|
|
12
|
+
*/
|
|
13
|
+
siteId?: SiteId;
|
|
14
|
+
/**
|
|
15
|
+
* The same site, passed rather than named — for a site that is deliberately
|
|
16
|
+
* not one of `ECOSYSTEM_SITES`.
|
|
17
|
+
* @default undefined
|
|
18
|
+
*/
|
|
19
|
+
site?: SiteRecord;
|
|
10
20
|
}
|
|
11
21
|
|
|
12
22
|
/**
|
|
@@ -18,7 +28,12 @@ export interface SiteThemeProps {
|
|
|
18
28
|
* in a component.
|
|
19
29
|
* @param props - The site whose palette is injected.
|
|
20
30
|
* @returns The rule, as a style element that applies wherever it is rendered.
|
|
31
|
+
* @throws {Error} When neither `site` nor `siteId` is given.
|
|
21
32
|
*/
|
|
22
33
|
export function SiteTheme(props: SiteThemeProps): ReactElement {
|
|
23
|
-
|
|
34
|
+
const site = props.site ?? props.siteId;
|
|
35
|
+
if (site === undefined) {
|
|
36
|
+
throw new Error('SiteTheme needs one of its `site` and `siteId` props');
|
|
37
|
+
}
|
|
38
|
+
return <style>{siteTokensCss(site)}</style>;
|
|
24
39
|
}
|
|
@@ -3,7 +3,7 @@ import type { CSSProperties, ReactElement } from 'react';
|
|
|
3
3
|
import { joinClassNames } from '../../shared/ui/joinClassNames.ts';
|
|
4
4
|
import { siteById } from '../core/lookup.ts';
|
|
5
5
|
import { siteNameColors } from '../core/nameColors.ts';
|
|
6
|
-
import type {
|
|
6
|
+
import type { SiteId, SiteRecord } from '../core/sites.ts';
|
|
7
7
|
|
|
8
8
|
/** What a site's written name needs. */
|
|
9
9
|
export interface WordmarkProps {
|
|
@@ -13,7 +13,7 @@ export interface WordmarkProps {
|
|
|
13
13
|
* required.
|
|
14
14
|
* @default undefined
|
|
15
15
|
*/
|
|
16
|
-
site?:
|
|
16
|
+
site?: SiteRecord;
|
|
17
17
|
/**
|
|
18
18
|
* The same site, named rather than passed, which is what a header knows.
|
|
19
19
|
* @default undefined
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { CSSProperties, ReactElement } from 'react';
|
|
1
|
+
import type { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
import { siteById } from '../core/lookup.ts';
|
|
4
|
-
import type {
|
|
4
|
+
import type { SiteId, SiteRecord } from '../core/sites.ts';
|
|
5
5
|
|
|
6
6
|
import { GLYPHS } from './glyphs.tsx';
|
|
7
7
|
|
|
@@ -19,13 +19,21 @@ export interface SiteMarkProps {
|
|
|
19
19
|
* and `siteId` is required.
|
|
20
20
|
* @default undefined
|
|
21
21
|
*/
|
|
22
|
-
site?:
|
|
22
|
+
site?: SiteRecord;
|
|
23
23
|
/**
|
|
24
24
|
* The same site, named rather than passed, for a header that knows only
|
|
25
25
|
* which site it is.
|
|
26
26
|
* @default undefined
|
|
27
27
|
*/
|
|
28
28
|
siteId?: SiteId;
|
|
29
|
+
/**
|
|
30
|
+
* What is drawn on the plate, in the same 32×32 box, given the colour its one
|
|
31
|
+
* answering element takes. It is how a site that is not one of the family,
|
|
32
|
+
* and so has no drawing in the shared set, still gets a mark of the family's
|
|
33
|
+
* shape.
|
|
34
|
+
* @default the family's drawing for that site
|
|
35
|
+
*/
|
|
36
|
+
glyph?: (accent: string) => ReactNode;
|
|
29
37
|
/**
|
|
30
38
|
* Edge of the square the mark is drawn in, in pixels.
|
|
31
39
|
* @default 28
|
|
@@ -57,13 +65,15 @@ export interface SiteMarkProps {
|
|
|
57
65
|
* The little logo of one site of the family.
|
|
58
66
|
* @param props - Which site, how big, and where its colours come from.
|
|
59
67
|
* @returns The mark, as an inline SVG.
|
|
60
|
-
* @throws {Error} When neither `site` nor `siteId` is given
|
|
68
|
+
* @throws {Error} When neither `site` nor `siteId` is given, or when the site
|
|
69
|
+
* is not one of the family and no `glyph` is.
|
|
61
70
|
*/
|
|
62
71
|
export function SiteMark(props: SiteMarkProps): ReactElement {
|
|
63
72
|
const {
|
|
64
73
|
className,
|
|
65
74
|
site,
|
|
66
75
|
siteId,
|
|
76
|
+
glyph,
|
|
67
77
|
size = 28,
|
|
68
78
|
plate = true,
|
|
69
79
|
colors = 'literal',
|
|
@@ -73,6 +83,10 @@ export function SiteMark(props: SiteMarkProps): ReactElement {
|
|
|
73
83
|
if (drawn === undefined) {
|
|
74
84
|
throw new Error('SiteMark needs one of its `site` and `siteId` props');
|
|
75
85
|
}
|
|
86
|
+
const draw = glyph ?? familyGlyph(drawn.id);
|
|
87
|
+
if (draw === undefined) {
|
|
88
|
+
throw new Error(`SiteMark has no drawing for ${drawn.id}: pass its glyph`);
|
|
89
|
+
}
|
|
76
90
|
|
|
77
91
|
const usesTokens = colors === 'tokens';
|
|
78
92
|
const plateFill = usesTokens ? 'var(--brand)' : drawn.mark.plate;
|
|
@@ -100,7 +114,11 @@ export function SiteMark(props: SiteMarkProps): ReactElement {
|
|
|
100
114
|
stroke={edge}
|
|
101
115
|
/>
|
|
102
116
|
) : null}
|
|
103
|
-
{
|
|
117
|
+
{draw(accent)}
|
|
104
118
|
</svg>
|
|
105
119
|
);
|
|
106
120
|
}
|
|
121
|
+
|
|
122
|
+
function familyGlyph(id: string): ((accent: string) => ReactNode) | undefined {
|
|
123
|
+
return Object.hasOwn(GLYPHS, id) ? GLYPHS[id as SiteId] : undefined;
|
|
124
|
+
}
|
package/src/seo/core/noscript.ts
CHANGED
|
@@ -167,7 +167,7 @@ function labelOf(route: NoscriptRoute): string {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
function familyList(
|
|
170
|
-
current:
|
|
170
|
+
current: string,
|
|
171
171
|
ecosystem: boolean | NoscriptEcosystem | undefined,
|
|
172
172
|
): string {
|
|
173
173
|
if (ecosystem === undefined || ecosystem === false) return '';
|
package/src/seo/core/pageMeta.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { siteDisplayName } from '../../ecosystem/core/lookup.ts';
|
|
16
|
-
import type {
|
|
16
|
+
import type { SiteId, SiteRecord } from '../../ecosystem/core/sites.ts';
|
|
17
17
|
import { escapeAttribute, escapeText } from '../../share/core/escape.ts';
|
|
18
18
|
|
|
19
19
|
import type { DocumentMeta } from './documentMeta.ts';
|
|
@@ -25,7 +25,7 @@ import { PAGE_HEAD_MARKER, fill } from './template.ts';
|
|
|
25
25
|
/** Which site is being served, and what it answers. */
|
|
26
26
|
export interface PageMetaOptions {
|
|
27
27
|
/** The site, named or passed. */
|
|
28
|
-
site:
|
|
28
|
+
site: SiteRecord | SiteId;
|
|
29
29
|
/** Every address it answers, each with its title and description. */
|
|
30
30
|
routes: readonly RouteMeta[];
|
|
31
31
|
/**
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { siteById } from '../../ecosystem/core/lookup.ts';
|
|
13
|
-
import type {
|
|
13
|
+
import type { SiteId, SiteRecord } from '../../ecosystem/core/sites.ts';
|
|
14
14
|
import { trimTrailingSlash } from '../../router/core/address.ts';
|
|
15
15
|
import { basePathOf } from '../../router/core/basePath.ts';
|
|
16
16
|
import { escapeText } from '../../share/core/escape.ts';
|
|
@@ -25,7 +25,7 @@ const HTTP_ORIGIN = /^https?:\/\//i;
|
|
|
25
25
|
/** What a crawler is told about the site as a whole. */
|
|
26
26
|
export interface SiteFilesOptions {
|
|
27
27
|
/** The site, named or passed. */
|
|
28
|
-
site:
|
|
28
|
+
site: SiteRecord | SiteId;
|
|
29
29
|
/** Every address it answers. */
|
|
30
30
|
routes: readonly RouteMeta[];
|
|
31
31
|
/**
|
|
@@ -71,7 +71,7 @@ ${entries}
|
|
|
71
71
|
* @param site - The site, named or passed.
|
|
72
72
|
* @returns Its record.
|
|
73
73
|
*/
|
|
74
|
-
export function resolveSite(site:
|
|
74
|
+
export function resolveSite(site: SiteRecord | SiteId): SiteRecord {
|
|
75
75
|
return typeof site === 'string' ? siteById(site) : site;
|
|
76
76
|
}
|
|
77
77
|
|
package/src/seo/vite/ogCard.ts
CHANGED
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
* a site must be able to import with none of the optional peers installed.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
+
import type { ReactNode } from 'react';
|
|
15
|
+
|
|
14
16
|
import { siteNameColors } from '../../ecosystem/core/nameColors.ts';
|
|
15
|
-
import type {
|
|
17
|
+
import type { SiteId, SiteRecord } from '../../ecosystem/core/sites.ts';
|
|
16
18
|
import { escapeText } from '../../share/core/escape.ts';
|
|
17
19
|
import { FAMILY_TOKEN_VALUES } from '../../tokens/core/familyTokens.ts';
|
|
18
20
|
import { resolveSite } from '../core/siteFiles.ts';
|
|
@@ -26,12 +28,18 @@ export const OG_HEIGHT = 630;
|
|
|
26
28
|
/** What the card says, beyond the site's own name and mark. */
|
|
27
29
|
export interface OgCardOptions {
|
|
28
30
|
/** The site, named or passed. */
|
|
29
|
-
site:
|
|
31
|
+
site: SiteRecord | SiteId;
|
|
30
32
|
/**
|
|
31
33
|
* The sentence under the name.
|
|
32
34
|
* @default the site's tagline
|
|
33
35
|
*/
|
|
34
36
|
description?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The drawing on the mark's plate, for a site the shared glyph set does not
|
|
39
|
+
* hold — see `SiteMark`.
|
|
40
|
+
* @default the family's drawing for that site
|
|
41
|
+
*/
|
|
42
|
+
glyph?: (accent: string) => ReactNode;
|
|
35
43
|
}
|
|
36
44
|
|
|
37
45
|
/**
|
|
@@ -58,7 +66,12 @@ export async function ogCardHtml(options: OgCardOptions): Promise<string> {
|
|
|
58
66
|
import('../../ecosystem/ui/marks.tsx'),
|
|
59
67
|
]);
|
|
60
68
|
const mark = renderToStaticMarkup(
|
|
61
|
-
createElement(SiteMark, {
|
|
69
|
+
createElement(SiteMark, {
|
|
70
|
+
site,
|
|
71
|
+
glyph: options.glyph,
|
|
72
|
+
size: 132,
|
|
73
|
+
colors: 'literal',
|
|
74
|
+
}),
|
|
62
75
|
);
|
|
63
76
|
const dot = site.name.dot === true ? '<span class="dot">.</span>' : '';
|
|
64
77
|
|
|
@@ -22,7 +22,7 @@ import { dirname, join, resolve } from 'node:path';
|
|
|
22
22
|
|
|
23
23
|
import type { Logger, Plugin } from 'vite';
|
|
24
24
|
|
|
25
|
-
import type {
|
|
25
|
+
import type { SiteId, SiteRecord } from '../../ecosystem/core/sites.ts';
|
|
26
26
|
import { trimTrailingSlash } from '../../router/core/address.ts';
|
|
27
27
|
import type { NoscriptText } from '../core/noscript.ts';
|
|
28
28
|
import { noscriptIndex } from '../core/noscript.ts';
|
|
@@ -38,7 +38,7 @@ import { PAGE_BODY_MARKER, PAGE_HEAD_MARKER, fill } from '../core/template.ts';
|
|
|
38
38
|
/** What the build needs to know to write the site's addresses. */
|
|
39
39
|
export interface PrerenderOptions {
|
|
40
40
|
/** The site, named or passed. */
|
|
41
|
-
site:
|
|
41
|
+
site: SiteRecord | SiteId;
|
|
42
42
|
/** Every address it answers, each with its title and description. */
|
|
43
43
|
routes: readonly RouteMeta[];
|
|
44
44
|
/**
|