react-cheminfo 0.34.0 → 0.36.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/README.md +28 -28
- package/bin/check-seo.mjs +333 -0
- package/lib/about/core/about.d.ts +1 -30
- package/lib/about/core/about.d.ts.map +1 -1
- package/lib/about/core/about.js +0 -16
- package/lib/about/core/about.js.map +1 -1
- package/lib/about/core/index.d.ts +0 -1
- package/lib/about/core/index.d.ts.map +1 -1
- package/lib/about/core/index.js +0 -1
- package/lib/about/core/index.js.map +1 -1
- package/lib/about/ui/AboutBuild.d.ts +2 -5
- package/lib/about/ui/AboutBuild.d.ts.map +1 -1
- package/lib/about/ui/AboutBuild.js +7 -19
- package/lib/about/ui/AboutBuild.js.map +1 -1
- package/lib/about/ui/AboutPage.d.ts +2 -2
- package/lib/about/ui/AboutPage.d.ts.map +1 -1
- package/lib/about/ui/AboutPage.js +3 -14
- package/lib/about/ui/AboutPage.js.map +1 -1
- package/lib/about/ui/AboutVersion.d.ts +0 -4
- package/lib/about/ui/AboutVersion.d.ts.map +1 -1
- package/lib/about/ui/AboutVersion.js +3 -31
- package/lib/about/ui/AboutVersion.js.map +1 -1
- package/lib/download/core/index.d.ts +0 -5
- package/lib/download/core/index.d.ts.map +1 -1
- package/lib/download/core/index.js +0 -3
- package/lib/download/core/index.js.map +1 -1
- package/lib/download/ui/FigureDownload.d.ts +4 -55
- package/lib/download/ui/FigureDownload.d.ts.map +1 -1
- package/lib/download/ui/FigureDownload.js +6 -66
- package/lib/download/ui/FigureDownload.js.map +1 -1
- package/lib/download/ui/FigureDownloadPanel.d.ts +16 -2
- package/lib/download/ui/FigureDownloadPanel.d.ts.map +1 -1
- package/lib/download/ui/FigureDownloadPanel.js +11 -30
- package/lib/download/ui/FigureDownloadPanel.js.map +1 -1
- package/lib/download/ui/figureDownloadHint.d.ts +30 -0
- package/lib/download/ui/figureDownloadHint.d.ts.map +1 -0
- package/lib/download/ui/figureDownloadHint.js +33 -0
- package/lib/download/ui/figureDownloadHint.js.map +1 -0
- package/lib/download/ui/index.d.ts +3 -10
- package/lib/download/ui/index.d.ts.map +1 -1
- package/lib/download/ui/index.js +1 -5
- package/lib/download/ui/index.js.map +1 -1
- package/lib/download/ui/useFigureActions.d.ts +50 -0
- package/lib/download/ui/useFigureActions.d.ts.map +1 -0
- package/lib/download/ui/useFigureActions.js +58 -0
- package/lib/download/ui/useFigureActions.js.map +1 -0
- package/lib/download/ui/useFigureDownload.d.ts +85 -0
- package/lib/download/ui/useFigureDownload.d.ts.map +1 -0
- package/lib/download/ui/useFigureDownload.js +75 -0
- package/lib/download/ui/useFigureDownload.js.map +1 -0
- package/lib/ecosystem/core/sites.d.ts.map +1 -1
- package/lib/ecosystem/core/sites.js +0 -40
- package/lib/ecosystem/core/sites.js.map +1 -1
- package/lib/ecosystem/core/types.d.ts +0 -10
- package/lib/ecosystem/core/types.d.ts.map +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
- package/lib/ir/core/irCommands.d.ts +2 -2
- package/lib/ir/core/irCommands.js +2 -2
- package/lib/ir/core/irCommands.js.map +1 -1
- package/lib/ir/ui/IrAboutDialog.d.ts.map +1 -1
- package/lib/ir/ui/IrAboutDialog.js +1 -1
- package/lib/ir/ui/IrAboutDialog.js.map +1 -1
- package/lib/ir/ui/IrCanvas.d.ts +6 -0
- package/lib/ir/ui/IrCanvas.d.ts.map +1 -1
- package/lib/ir/ui/IrCanvas.js +2 -2
- package/lib/ir/ui/IrCanvas.js.map +1 -1
- package/lib/ir/ui/IrShell.d.ts.map +1 -1
- package/lib/ir/ui/IrShell.js +16 -11
- package/lib/ir/ui/IrShell.js.map +1 -1
- package/lib/ir/ui/IrToolbar.d.ts +11 -1
- package/lib/ir/ui/IrToolbar.d.ts.map +1 -1
- package/lib/ir/ui/IrToolbar.js +12 -2
- package/lib/ir/ui/IrToolbar.js.map +1 -1
- package/lib/ir/ui/index.d.ts +1 -0
- package/lib/ir/ui/index.d.ts.map +1 -1
- package/lib/ir/ui/index.js.map +1 -1
- package/lib/language/core/index.d.ts +2 -0
- package/lib/language/core/index.d.ts.map +1 -1
- package/lib/language/core/index.js +1 -0
- package/lib/language/core/index.js.map +1 -1
- package/lib/language/core/languagePath.d.ts +52 -0
- package/lib/language/core/languagePath.d.ts.map +1 -0
- package/lib/language/core/languagePath.js +65 -0
- package/lib/language/core/languagePath.js.map +1 -0
- package/lib/locales/de.json +2 -4
- package/lib/locales/en.json +2 -4
- package/lib/locales/es.json +2 -4
- package/lib/locales/fr.json +2 -4
- package/lib/locales/it.json +2 -4
- package/lib/overlay/ui/OverlayPanel.d.ts +6 -0
- package/lib/overlay/ui/OverlayPanel.d.ts.map +1 -1
- package/lib/overlay/ui/OverlayPanel.js +2 -2
- package/lib/overlay/ui/OverlayPanel.js.map +1 -1
- package/lib/overlay/ui/overlayPanelStyles.d.ts +2 -1
- package/lib/overlay/ui/overlayPanelStyles.d.ts.map +1 -1
- package/lib/overlay/ui/overlayPanelStyles.js +3 -1
- package/lib/overlay/ui/overlayPanelStyles.js.map +1 -1
- package/lib/periodic/ui/ElementCell.d.ts +0 -6
- package/lib/periodic/ui/ElementCell.d.ts.map +1 -1
- package/lib/periodic/ui/ElementCell.js +34 -30
- package/lib/periodic/ui/ElementCell.js.map +1 -1
- package/lib/periodic/ui/PeriodicTable.d.ts.map +1 -1
- package/lib/periodic/ui/PeriodicTable.js +12 -15
- package/lib/periodic/ui/PeriodicTable.js.map +1 -1
- package/lib/seo/core/alternates.d.ts +40 -0
- package/lib/seo/core/alternates.d.ts.map +1 -0
- package/lib/seo/core/alternates.js +42 -0
- package/lib/seo/core/alternates.js.map +1 -0
- package/lib/seo/core/index.d.ts +3 -0
- package/lib/seo/core/index.d.ts.map +1 -1
- package/lib/seo/core/index.js +2 -0
- package/lib/seo/core/index.js.map +1 -1
- package/lib/seo/core/noscript.d.ts +9 -0
- package/lib/seo/core/noscript.d.ts.map +1 -1
- package/lib/seo/core/noscript.js +7 -2
- package/lib/seo/core/noscript.js.map +1 -1
- package/lib/seo/core/pageMeta.d.ts +23 -0
- package/lib/seo/core/pageMeta.d.ts.map +1 -1
- package/lib/seo/core/pageMeta.js +52 -3
- package/lib/seo/core/pageMeta.js.map +1 -1
- package/lib/seo/core/pageProse.d.ts +76 -0
- package/lib/seo/core/pageProse.d.ts.map +1 -0
- package/lib/seo/core/pageProse.js +92 -0
- package/lib/seo/core/pageProse.js.map +1 -0
- package/lib/seo/core/routeProblems.d.ts +33 -0
- package/lib/seo/core/routeProblems.d.ts.map +1 -0
- package/lib/seo/core/routeProblems.js +89 -0
- package/lib/seo/core/routeProblems.js.map +1 -0
- package/lib/seo/core/routes.d.ts +14 -0
- package/lib/seo/core/routes.d.ts.map +1 -1
- package/lib/seo/core/routes.js.map +1 -1
- package/lib/seo/core/siteFiles.d.ts.map +1 -1
- package/lib/seo/core/siteFiles.js +2 -1
- package/lib/seo/core/siteFiles.js.map +1 -1
- package/lib/seo/vite/prerender.d.ts +13 -0
- package/lib/seo/vite/prerender.d.ts.map +1 -1
- package/lib/seo/vite/prerender.js +17 -10
- package/lib/seo/vite/prerender.js.map +1 -1
- package/package.json +2 -1
- package/src/about/core/about.ts +1 -51
- package/src/about/core/index.ts +0 -1
- package/src/about/ui/AboutBuild.tsx +8 -37
- package/src/about/ui/AboutPage.tsx +8 -64
- package/src/about/ui/AboutVersion.tsx +5 -45
- package/src/download/core/index.ts +0 -25
- package/src/download/ui/FigureDownload.tsx +11 -148
- package/src/download/ui/FigureDownloadPanel.tsx +46 -45
- package/src/download/ui/figureDownloadHint.ts +52 -0
- package/src/download/ui/index.ts +6 -10
- package/src/download/ui/useFigureActions.ts +113 -0
- package/src/download/ui/useFigureDownload.tsx +191 -0
- package/src/ecosystem/core/sites.ts +0 -40
- package/src/ecosystem/core/types.ts +0 -10
- package/src/ir/core/irCommands.ts +2 -2
- package/src/ir/ui/IrAboutDialog.tsx +0 -13
- package/src/ir/ui/IrCanvas.tsx +8 -2
- package/src/ir/ui/IrShell.tsx +23 -25
- package/src/ir/ui/IrToolbar.tsx +36 -6
- package/src/ir/ui/index.ts +1 -0
- package/src/language/core/index.ts +2 -0
- package/src/language/core/languagePath.ts +78 -0
- package/src/locales/de.json +2 -4
- package/src/locales/en.json +2 -4
- package/src/locales/es.json +2 -4
- package/src/locales/fr.json +2 -4
- package/src/locales/it.json +2 -4
- package/src/overlay/ui/OverlayPanel.tsx +8 -2
- package/src/overlay/ui/overlayPanelStyles.ts +3 -0
- package/src/periodic/ui/ElementCell.tsx +34 -37
- package/src/periodic/ui/PeriodicTable.tsx +12 -17
- package/src/seo/core/alternates.ts +65 -0
- package/src/seo/core/index.ts +3 -0
- package/src/seo/core/noscript.ts +18 -2
- package/src/seo/core/pageMeta.ts +74 -3
- package/src/seo/core/pageProse.ts +146 -0
- package/src/seo/core/routeProblems.ts +111 -0
- package/src/seo/core/routes.ts +14 -0
- package/src/seo/core/siteFiles.ts +2 -1
- package/src/seo/vite/prerender.ts +30 -11
- package/lib/about/core/repository.d.ts +0 -14
- package/lib/about/core/repository.d.ts.map +0 -1
- package/lib/about/core/repository.js +0 -21
- package/lib/about/core/repository.js.map +0 -1
- package/lib/download/core/exportStyles.d.ts +0 -22
- package/lib/download/core/exportStyles.d.ts.map +0 -1
- package/lib/download/core/exportStyles.js +0 -19
- package/lib/download/core/exportStyles.js.map +0 -1
- package/lib/download/core/imageResolution.d.ts +0 -88
- package/lib/download/core/imageResolution.d.ts.map +0 -1
- package/lib/download/core/imageResolution.js +0 -77
- package/lib/download/core/imageResolution.js.map +0 -1
- package/lib/download/core/pictureExport.d.ts +0 -93
- package/lib/download/core/pictureExport.d.ts.map +0 -1
- package/lib/download/core/pictureExport.js +0 -116
- package/lib/download/core/pictureExport.js.map +0 -1
- package/lib/download/ui/ExportDialogFrame.d.ts +0 -46
- package/lib/download/ui/ExportDialogFrame.d.ts.map +0 -1
- package/lib/download/ui/ExportDialogFrame.js +0 -24
- package/lib/download/ui/ExportDialogFrame.js.map +0 -1
- package/lib/download/ui/ExportImageDialog.d.ts +0 -47
- package/lib/download/ui/ExportImageDialog.d.ts.map +0 -1
- package/lib/download/ui/ExportImageDialog.js +0 -25
- package/lib/download/ui/ExportImageDialog.js.map +0 -1
- package/lib/download/ui/ExportNameField.d.ts +0 -29
- package/lib/download/ui/ExportNameField.d.ts.map +0 -1
- package/lib/download/ui/ExportNameField.js +0 -99
- package/lib/download/ui/ExportNameField.js.map +0 -1
- package/lib/download/ui/ExportPictureSection.d.ts +0 -38
- package/lib/download/ui/ExportPictureSection.d.ts.map +0 -1
- package/lib/download/ui/ExportPictureSection.js +0 -48
- package/lib/download/ui/ExportPictureSection.js.map +0 -1
- package/lib/download/ui/useDrawingBox.d.ts +0 -23
- package/lib/download/ui/useDrawingBox.d.ts.map +0 -1
- package/lib/download/ui/useDrawingBox.js +0 -21
- package/lib/download/ui/useDrawingBox.js.map +0 -1
- package/src/about/core/repository.ts +0 -22
- package/src/download/core/exportStyles.ts +0 -20
- package/src/download/core/imageResolution.ts +0 -118
- package/src/download/core/pictureExport.ts +0 -207
- package/src/download/ui/ExportDialogFrame.tsx +0 -86
- package/src/download/ui/ExportImageDialog.tsx +0 -91
- package/src/download/ui/ExportNameField.tsx +0 -148
- package/src/download/ui/ExportPictureSection.tsx +0 -142
- package/src/download/ui/useDrawingBox.ts +0 -37
|
@@ -7,7 +7,7 @@ import { useChromeT } from "../../i18n/ui/useT.js";
|
|
|
7
7
|
* @returns The cell.
|
|
8
8
|
*/
|
|
9
9
|
export function ElementCell(props) {
|
|
10
|
-
const { className, atomicNumber, symbol, name, swatch, column, row, onSelect, detail = '',
|
|
10
|
+
const { className, atomicNumber, symbol, name, swatch, column, row, onSelect, detail = '', isSelected = false, isIncluded = true, onHover, } = props;
|
|
11
11
|
const t = useChromeT();
|
|
12
12
|
const [isHovered, setIsHovered] = useState(false);
|
|
13
13
|
return (_jsxs("button", { type: "button", className: className, "data-testid": `element-${symbol}`, "data-symbol": symbol, title: detail === '' ? name : `${name} · ${detail}`, "aria-label": t('periodic.cellLabel', {
|
|
@@ -41,7 +41,7 @@ export function ElementCell(props) {
|
|
|
41
41
|
filter: isHovered ? 'brightness(1.08)' : undefined,
|
|
42
42
|
}, children: [_jsx("span", { style: numberStyle, children: atomicNumber }), _jsx("span", { style: {
|
|
43
43
|
...symbolStyle,
|
|
44
|
-
fontSize: symbolFontSize(symbol
|
|
44
|
+
fontSize: symbolFontSize(symbol),
|
|
45
45
|
}, children: symbol }), detail === '' ? null : (_jsx("span", { style: { ...detailStyle, fontSize: detailFontSize(detail) }, children: detail }))] }));
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
@@ -51,12 +51,10 @@ export function ElementCell(props) {
|
|
|
51
51
|
* ones whose second letter is an `m` — which are written a tenth smaller
|
|
52
52
|
* rather than run into the edges of their cell.
|
|
53
53
|
* @param symbol - The chemical symbol.
|
|
54
|
-
* @param writesDetail - Whether the table writes a third line under it.
|
|
55
54
|
* @returns A CSS length.
|
|
56
55
|
*/
|
|
57
|
-
function symbolFontSize(symbol
|
|
58
|
-
|
|
59
|
-
return fitted(symbolWidthInEm(symbol), cap, '0.5rem');
|
|
56
|
+
function symbolFontSize(symbol) {
|
|
57
|
+
return fitted(symbolWidthInEm(symbol), SYMBOL_CQW, '0.5rem');
|
|
60
58
|
}
|
|
61
59
|
/**
|
|
62
60
|
* The size the third line takes so the whole of it is written.
|
|
@@ -121,60 +119,66 @@ function detailWidthInEm(detail) {
|
|
|
121
119
|
const TABULAR_EM = 0.6;
|
|
122
120
|
/** The size the symbol is written at wherever it fits, as a share of the table. */
|
|
123
121
|
const SYMBOL_CQW = '2.4cqw';
|
|
124
|
-
/** The same, in a table that writes nothing under the symbol. */
|
|
125
|
-
const SYMBOL_ALONE_CQW = '2.8cqw';
|
|
126
122
|
/**
|
|
127
123
|
* The tallest the third line is ever written, as a share of the table.
|
|
128
124
|
*
|
|
129
|
-
* Close to
|
|
130
|
-
*
|
|
131
|
-
*
|
|
125
|
+
* Close to two thirds of the symbol: the symbol is how a cell is found, but
|
|
126
|
+
* the value is what the table is being read for, and a value half the size of
|
|
127
|
+
* the symbol is the one thing on the cell a class cannot make out.
|
|
132
128
|
*/
|
|
133
|
-
const DETAIL_CQW = '1.
|
|
129
|
+
const DETAIL_CQW = '1.6cqw';
|
|
130
|
+
/**
|
|
131
|
+
* The band at each end of a cell: the atomic number at the top, whatever the
|
|
132
|
+
* tool writes at the bottom.
|
|
133
|
+
*
|
|
134
|
+
* They are one length, not two, and that is what makes the symbol between them
|
|
135
|
+
* sit at the centre of the cell rather than near it — a bottom band wider than
|
|
136
|
+
* the top one by a third lifted every symbol in the table two pixels.
|
|
137
|
+
*/
|
|
138
|
+
const EDGE_BAND = '1.8cqw';
|
|
134
139
|
/** How wide one column is, as a share of the table's width. */
|
|
135
140
|
const CELL_CQW = '4.85cqw';
|
|
136
141
|
/** What the border and the padding of a cell take off that width. */
|
|
137
142
|
const CELL_CHROME = '4px';
|
|
143
|
+
/**
|
|
144
|
+
* A cell is three bands of its own, and every cell has all three.
|
|
145
|
+
*
|
|
146
|
+
* The atomic number is in the top band, against its left edge; the symbol is
|
|
147
|
+
* centred in the middle one; whatever the tool writes is centred in the
|
|
148
|
+
* bottom one. The bands keep their height whether or not anything is written
|
|
149
|
+
* in the last of them, so a number sits at one height across the whole table
|
|
150
|
+
* and a symbol at one other — before this, both rode on a stack the cell
|
|
151
|
+
* centred and moved whenever a neighbour's value was written smaller.
|
|
152
|
+
*/
|
|
138
153
|
const cellStyle = {
|
|
139
|
-
alignItems: 'center',
|
|
140
154
|
border: '1px solid rgb(255 255 255 / 0.55)',
|
|
141
155
|
borderRadius: 3,
|
|
142
156
|
cursor: 'pointer',
|
|
143
|
-
display: '
|
|
144
|
-
flexDirection: 'column',
|
|
157
|
+
display: 'grid',
|
|
145
158
|
font: 'inherit',
|
|
146
|
-
|
|
159
|
+
gridTemplateRows: `${EDGE_BAND} 1fr ${EDGE_BAND}`,
|
|
160
|
+
justifyItems: 'center',
|
|
147
161
|
minWidth: 0,
|
|
148
162
|
overflow: 'hidden',
|
|
149
163
|
padding: '1px',
|
|
150
|
-
// The corner the atomic number is pinned into.
|
|
151
|
-
position: 'relative',
|
|
152
164
|
transition: 'opacity 120ms ease, filter 120ms ease',
|
|
153
165
|
};
|
|
154
|
-
/**
|
|
155
|
-
* The atomic number sits out of the flow, in the corner.
|
|
156
|
-
*
|
|
157
|
-
* In the flow it rode on top of a stack the cell centres, so it moved down
|
|
158
|
-
* whenever what is written under the symbol was written smaller — the numbers
|
|
159
|
-
* of a row then sat at as many heights as the row had word lengths. Out of it,
|
|
160
|
-
* the number is in the same corner of every cell, and the symbol is centred in
|
|
161
|
-
* the cell rather than in what is left of it.
|
|
162
|
-
*/
|
|
163
166
|
const numberStyle = {
|
|
167
|
+
alignSelf: 'start',
|
|
164
168
|
fontSize: 'max(0.33rem, 1.1cqw)',
|
|
165
169
|
fontVariantNumeric: 'tabular-nums',
|
|
166
|
-
|
|
170
|
+
justifySelf: 'start',
|
|
167
171
|
lineHeight: 1,
|
|
168
172
|
opacity: 0.8,
|
|
169
|
-
position: 'absolute',
|
|
170
|
-
top: 'max(1px, 0.14cqw)',
|
|
171
173
|
};
|
|
172
174
|
const symbolStyle = {
|
|
175
|
+
alignSelf: 'center',
|
|
173
176
|
fontWeight: 700,
|
|
174
177
|
letterSpacing: '-0.02em',
|
|
175
178
|
lineHeight: 1.02,
|
|
176
179
|
};
|
|
177
180
|
const detailStyle = {
|
|
181
|
+
alignSelf: 'center',
|
|
178
182
|
fontVariantNumeric: 'tabular-nums',
|
|
179
183
|
lineHeight: 1,
|
|
180
184
|
maxWidth: '100%',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementCell.js","sourceRoot":"","sources":["../../../src/periodic/ui/ElementCell.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AA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 -14,7 +14,6 @@ import { HeaderStrips, InnerTransitionMarkers, } from "./PeriodicTableChrome.js"
|
|
|
14
14
|
export function PeriodicTable(props) {
|
|
15
15
|
const { selected, onSelect, swatchOf = defaultSwatchOf, detailOf, nameOf = defaultNameOf, isIncluded, inset, headers = false, onSelectRange, legend = false, markers = true, keyboard = true, onHover, className, } = props;
|
|
16
16
|
const t = useChromeT();
|
|
17
|
-
const writesDetail = detailOf !== undefined;
|
|
18
17
|
const gridRef = useRef(null);
|
|
19
18
|
const cameFromKeyRef = useRef(false);
|
|
20
19
|
const offset = headers ? 1 : 0;
|
|
@@ -36,7 +35,7 @@ export function PeriodicTable(props) {
|
|
|
36
35
|
cameFromKeyRef.current = true;
|
|
37
36
|
onSelect(next.symbol);
|
|
38
37
|
}
|
|
39
|
-
return (_jsxs("div", { className: className, style: rootStyle, children: [_jsxs("div", { ref: gridRef, role: "grid", "aria-label": t('periodic.table'), "data-testid": "periodic-table", style: gridStyle(headers
|
|
38
|
+
return (_jsxs("div", { className: className, style: rootStyle, children: [_jsxs("div", { ref: gridRef, role: "grid", "aria-label": t('periodic.table'), "data-testid": "periodic-table", style: gridStyle(headers), onKeyDown: handleKeyDown, children: [headers ? _jsx(HeaderStrips, { onSelectRange: onSelectRange }) : null, inset === undefined ? null : (_jsx("div", { style: insetStyle(offset), children: inset })), markers ? _jsx(InnerTransitionMarkers, { offset: offset }) : null, placedElements().map(({ element, cell }) => (_jsx(ElementCell, { atomicNumber: element.atomicNumber, symbol: element.symbol, name: nameOf(element), detail: detailOf?.(element), swatch: swatchOf(element), isSelected: element.symbol === selected, isIncluded: isIncluded?.(element), column: cell.column + offset, row: cell.row + offset, onSelect: onSelect ?? noop, onHover: onHover }, element.symbol)))] }), legend ? _jsx(CategoryLegend, {}) : null] }));
|
|
40
39
|
}
|
|
41
40
|
/**
|
|
42
41
|
* Where what the caller writes in the empty block is placed.
|
|
@@ -47,8 +46,9 @@ function insetStyle(offset) {
|
|
|
47
46
|
return {
|
|
48
47
|
alignItems: 'center',
|
|
49
48
|
display: 'flex',
|
|
50
|
-
//
|
|
51
|
-
|
|
49
|
+
// A column of air on each side, so the writing reads as sitting in the
|
|
50
|
+
// block rather than as running into the cells beside it.
|
|
51
|
+
padding: '0 2.4cqw',
|
|
52
52
|
gridColumn: `${String(EMPTY_BLOCK.column + offset)} / span ${String(EMPTY_BLOCK.columnSpan)}`,
|
|
53
53
|
gridRow: `${String(EMPTY_BLOCK.row + offset)} / span ${String(EMPTY_BLOCK.rowSpan)}`,
|
|
54
54
|
// A share of the table, with a floor, exactly as a cell sizes its symbol:
|
|
@@ -75,13 +75,13 @@ const MIN_WIDTH = 280;
|
|
|
75
75
|
/**
|
|
76
76
|
* How tall one row of elements is, as a share of the table's width.
|
|
77
77
|
*
|
|
78
|
-
* A column is about 5.
|
|
79
|
-
*
|
|
80
|
-
* cell need to be
|
|
78
|
+
* A column is about 5.2% of that width, so a cell is a third taller than it is
|
|
79
|
+
* wide — the proportion of a wall chart, and the room the three bands of a
|
|
80
|
+
* cell need to be read from the back of a room. It is the same height in every
|
|
81
|
+
* table: a cell keeps the band it writes a value in whether or not that table
|
|
82
|
+
* writes one.
|
|
81
83
|
*/
|
|
82
|
-
const ROW_HEIGHT = '6.
|
|
83
|
-
/** The same, in a table that writes nothing under the symbol. */
|
|
84
|
-
const ROW_HEIGHT_ALONE = '4.9cqw';
|
|
84
|
+
const ROW_HEIGHT = '6.8cqw';
|
|
85
85
|
/** The band the two inner-transition series were lifted out across. */
|
|
86
86
|
const SERIES_GAP = 'max(6px, 1.1cqw)';
|
|
87
87
|
const rootStyle = {
|
|
@@ -104,14 +104,11 @@ const baseGridStyle = {
|
|
|
104
104
|
* The grid the cells are placed on.
|
|
105
105
|
* @param headers - Whether a leading column and row hold the period and group
|
|
106
106
|
* numbers.
|
|
107
|
-
* @param writesDetail - Whether a cell writes a third line, which is what a
|
|
108
|
-
* row is tall enough for.
|
|
109
107
|
* @returns The style of the grid.
|
|
110
108
|
*/
|
|
111
|
-
function gridStyle(headers
|
|
112
|
-
const row = writesDetail ? ROW_HEIGHT : ROW_HEIGHT_ALONE;
|
|
109
|
+
function gridStyle(headers) {
|
|
113
110
|
// The eighth row is the gap the inner-transition series are lifted out into.
|
|
114
|
-
const rows = `repeat(7, ${
|
|
111
|
+
const rows = `repeat(7, ${ROW_HEIGHT}) ${SERIES_GAP} repeat(2, ${ROW_HEIGHT})`;
|
|
115
112
|
if (!headers) {
|
|
116
113
|
return {
|
|
117
114
|
...baseGridStyle,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PeriodicTable.js","sourceRoot":"","sources":["../../../src/periodic/ui/PeriodicTable.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,OAAO,EACL,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAmB,CAAC;AAChD,OAAO,EACL,YAAY,EACZ,sBAAsB,GACvB,MAAM,0BAA2B,CAAC;AAwFnC;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,MAAM,EACJ,QAAQ,EACR,QAAQ,EACR,QAAQ,GAAG,eAAe,EAC1B,QAAQ,EACR,MAAM,GAAG,aAAa,EACtB,UAAU,EACV,KAAK,EACL,OAAO,GAAG,KAAK,EACf,aAAa,EACb,MAAM,GAAG,KAAK,EACd,OAAO,GAAG,IAAI,EACd,QAAQ,GAAG,IAAI,EACf,OAAO,EACP,SAAS,GACV,GAAG,KAAK,CAAC;IAEV,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC;IACvB,MAAM,
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C"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tags that tell a search engine five addresses are one page written five
|
|
3
|
+
* times.
|
|
4
|
+
*
|
|
5
|
+
* Without them a translated site is read as five sites that happen to look
|
|
6
|
+
* alike: the French tutorial competes with the English one instead of being
|
|
7
|
+
* offered to a French reader, and a search engine picks one of them to keep.
|
|
8
|
+
* With them each address is served to the audience it was written for, and the
|
|
9
|
+
* four it was not stop diluting it.
|
|
10
|
+
*
|
|
11
|
+
* Every page names **every** language including itself — a set that does not
|
|
12
|
+
* list the page it is on is ignored whole — plus `x-default`, which is where a
|
|
13
|
+
* reader whose language we do not speak is sent.
|
|
14
|
+
*/
|
|
15
|
+
import type { Language } from '../../i18n/core/languages.ts';
|
|
16
|
+
/** Which page, in which languages, served from where. */
|
|
17
|
+
export interface AlternateOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Where the site is served, mount path included and no trailing slash, e.g.
|
|
20
|
+
* `https://3d.cheminfo.org`.
|
|
21
|
+
*/
|
|
22
|
+
origin: string;
|
|
23
|
+
/**
|
|
24
|
+
* The page, from the site's own root and with no language prefix on it, e.g.
|
|
25
|
+
* `/tutorial`.
|
|
26
|
+
*/
|
|
27
|
+
path: string;
|
|
28
|
+
/**
|
|
29
|
+
* Every language the site is written in. One language alone means there is
|
|
30
|
+
* nothing to point at, and no tag is written.
|
|
31
|
+
*/
|
|
32
|
+
languages: readonly Language[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The `rel="alternate"` block for one page of a translated site.
|
|
36
|
+
* @param options - The page, its languages and where the site is served.
|
|
37
|
+
* @returns The tags, one per line, or `''` when the site speaks one language.
|
|
38
|
+
*/
|
|
39
|
+
export declare function alternateLinkTags(options: AlternateOptions): string;
|
|
40
|
+
//# sourceMappingURL=alternates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alternates.d.ts","sourceRoot":"","sources":["../../../src/seo/core/alternates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAK7D,yDAAyD;AACzD,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,SAAS,EAAE,SAAS,QAAQ,EAAE,CAAC;CAChC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAYnE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tags that tell a search engine five addresses are one page written five
|
|
3
|
+
* times.
|
|
4
|
+
*
|
|
5
|
+
* Without them a translated site is read as five sites that happen to look
|
|
6
|
+
* alike: the French tutorial competes with the English one instead of being
|
|
7
|
+
* offered to a French reader, and a search engine picks one of them to keep.
|
|
8
|
+
* With them each address is served to the audience it was written for, and the
|
|
9
|
+
* four it was not stop diluting it.
|
|
10
|
+
*
|
|
11
|
+
* Every page names **every** language including itself — a set that does not
|
|
12
|
+
* list the page it is on is ignored whole — plus `x-default`, which is where a
|
|
13
|
+
* reader whose language we do not speak is sent.
|
|
14
|
+
*/
|
|
15
|
+
import { DEFAULT_LANGUAGE } from "../../i18n/core/languages.js";
|
|
16
|
+
import { withLanguagePath } from "../../language/core/languagePath.js";
|
|
17
|
+
import { escapeAttribute } from "../../share/core/escape.js";
|
|
18
|
+
/**
|
|
19
|
+
* The `rel="alternate"` block for one page of a translated site.
|
|
20
|
+
* @param options - The page, its languages and where the site is served.
|
|
21
|
+
* @returns The tags, one per line, or `''` when the site speaks one language.
|
|
22
|
+
*/
|
|
23
|
+
export function alternateLinkTags(options) {
|
|
24
|
+
const { origin, path, languages } = options;
|
|
25
|
+
if (languages.length < 2)
|
|
26
|
+
return '';
|
|
27
|
+
const tags = [];
|
|
28
|
+
for (const language of languages) {
|
|
29
|
+
tags.push(linkTag(language, address(origin, language, path)));
|
|
30
|
+
}
|
|
31
|
+
// A reader we have no language for gets the unprefixed address, which is the
|
|
32
|
+
// one every link handed out before the site was translated already points at.
|
|
33
|
+
tags.push(linkTag('x-default', address(origin, DEFAULT_LANGUAGE, path)));
|
|
34
|
+
return tags.join('\n');
|
|
35
|
+
}
|
|
36
|
+
function address(origin, language, path) {
|
|
37
|
+
return `${origin}${withLanguagePath(language, path)}`;
|
|
38
|
+
}
|
|
39
|
+
function linkTag(hreflang, href) {
|
|
40
|
+
return `<link rel="alternate" hreflang="${escapeAttribute(hreflang)}" href="${escapeAttribute(href)}" />`;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=alternates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alternates.js","sourceRoot":"","sources":["../../../src/seo/core/alternates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAqB7D;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAyB;IACzD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC5C,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IAEpC,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC;IACD,6EAA6E;IAC7E,8EAA8E;IAC9E,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACzE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,OAAO,CAAC,MAAc,EAAE,QAAkB,EAAE,IAAY;IAC/D,OAAO,GAAG,MAAM,GAAG,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC;AACxD,CAAC;AAED,SAAS,OAAO,CAAC,QAAgB,EAAE,IAAY;IAC7C,OAAO,mCAAmC,eAAe,CAAC,QAAQ,CAAC,WAAW,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC;AAC5G,CAAC"}
|
package/lib/seo/core/index.d.ts
CHANGED
|
@@ -4,10 +4,13 @@ export type { NoscriptEcosystem, NoscriptHrefs, NoscriptOptions, NoscriptRoute,
|
|
|
4
4
|
export { noscriptIndex } from './noscript.ts';
|
|
5
5
|
export type { PageMetaOptions } from './pageMeta.ts';
|
|
6
6
|
export { injectPageMeta, pageDocumentMeta, pageHeadTags } from './pageMeta.ts';
|
|
7
|
+
export type { PageContent, PageSection, PageTable } from './pageProse.ts';
|
|
8
|
+
export { pageProseHtml } from './pageProse.ts';
|
|
7
9
|
export type { PlainDescriptionOptions } from './plainDescription.ts';
|
|
8
10
|
export { plainDescription, plainProse } from './plainDescription.ts';
|
|
9
11
|
export type { RobotsDisallow } from './robots.ts';
|
|
10
12
|
export { robotsTxt } from './robots.ts';
|
|
13
|
+
export { routeProblems, withheldPhrase } from './routeProblems.ts';
|
|
11
14
|
export type { RouteMeta } from './routes.ts';
|
|
12
15
|
export { assertRoutes, homeRoute, pageMetaFor, routeFor } from './routes.ts';
|
|
13
16
|
export type { SiteFilesOptions } from './siteFiles.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/seo/core/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,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3D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/lib/seo/core/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export { writeDocumentMeta } from "./documentMeta.js";
|
|
2
2
|
export { noscriptIndex } from "./noscript.js";
|
|
3
3
|
export { injectPageMeta, pageDocumentMeta, pageHeadTags } from "./pageMeta.js";
|
|
4
|
+
export { pageProseHtml } from "./pageProse.js";
|
|
4
5
|
export { plainDescription, plainProse } from "./plainDescription.js";
|
|
5
6
|
export { robotsTxt } from "./robots.js";
|
|
7
|
+
export { routeProblems, withheldPhrase } from "./routeProblems.js";
|
|
6
8
|
export { assertRoutes, homeRoute, pageMetaFor, routeFor } from "./routes.js";
|
|
7
9
|
export { sitemapXml } from "./siteFiles.js";
|
|
8
10
|
export { startDocumentMeta } from "./startDocumentMeta.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/seo/core/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAQtD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE/E,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/seo/core/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAQtD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE/E,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* the tool needs JavaScript, and links the addresses it answers.
|
|
7
7
|
*/
|
|
8
8
|
import type { SiteId } from '../../ecosystem/core/sites.ts';
|
|
9
|
+
import type { PageContent } from './pageProse.ts';
|
|
9
10
|
import type { RouteMeta } from './routes.ts';
|
|
10
11
|
import type { SiteFilesOptions } from './siteFiles.ts';
|
|
11
12
|
/** How the addresses of the site's own pages are written. */
|
|
@@ -80,6 +81,14 @@ export interface NoscriptText {
|
|
|
80
81
|
export interface NoscriptOptions extends Omit<SiteFilesOptions, 'routes'>, Omit<NoscriptText, 'routes'> {
|
|
81
82
|
/** The addresses it links, each with the label it is linked under. */
|
|
82
83
|
routes: readonly NoscriptRoute[];
|
|
84
|
+
/**
|
|
85
|
+
* What the page being written says, above the crawl path. The block is the
|
|
86
|
+
* only text a crawler is handed before anything runs, so a page with nothing
|
|
87
|
+
* of its own here is indexed on its title and on this site's menu — which
|
|
88
|
+
* every other page of the site carries too.
|
|
89
|
+
* @default undefined — the block is the menu alone
|
|
90
|
+
*/
|
|
91
|
+
content?: PageContent;
|
|
83
92
|
}
|
|
84
93
|
/**
|
|
85
94
|
* The `noscript` block, ready to put in the body.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noscript.d.ts","sourceRoot":"","sources":["../../../src/seo/core/noscript.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAiB,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAK3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,6DAA6D;AAC7D,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,UAAU,CAAC;AAEpD,6DAA6D;AAC7D,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C;;;;OAIG;IACH,QAAQ,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;CACrC;AAED,6DAA6D;AAC7D,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,6EAA6E;AAC7E,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,iBAAiB,CAAC;IACxC;;;;;;;;;OASG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;CACnC;AAED,yDAAyD;AACzD,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,EAAE,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,QAAQ,CAAC;IACtE,sEAAsE;IACtE,MAAM,EAAE,SAAS,aAAa,EAAE,CAAC;IACjC;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAoB9D"}
|
package/lib/seo/core/noscript.js
CHANGED
|
@@ -9,6 +9,7 @@ import { siteById, siteDisplayName } from "../../ecosystem/core/lookup.js";
|
|
|
9
9
|
import { ECOSYSTEM_SITES, siteUrl } from "../../ecosystem/core/sites.js";
|
|
10
10
|
import { joinBasePath } from "../../router/core/basePath.js";
|
|
11
11
|
import { escapeAttribute, escapeText } from "../../share/core/escape.js";
|
|
12
|
+
import { pageProseHtml } from "./pageProse.js";
|
|
12
13
|
import { mountPathOf, resolveSite } from "./siteFiles.js";
|
|
13
14
|
/**
|
|
14
15
|
* The `noscript` block, ready to put in the body.
|
|
@@ -26,11 +27,15 @@ export function noscriptIndex(options) {
|
|
|
26
27
|
const site = resolveSite(options.site);
|
|
27
28
|
const hrefs = options.hrefs ?? 'absolute';
|
|
28
29
|
const mount = hrefs === 'absolute' ? mountPathOf(options) : '';
|
|
29
|
-
const
|
|
30
|
+
const content = options.content;
|
|
31
|
+
// The page's own name answers the title it is indexed under, so it wins over
|
|
32
|
+
// a heading the site writes for every one of its pages at once.
|
|
33
|
+
const heading = escapeText(content?.heading ?? options.heading ?? siteDisplayName(site));
|
|
30
34
|
const intro = escapeText(options.intro ??
|
|
31
35
|
`${site.tagline} This tool needs JavaScript; these are the pages it offers:`);
|
|
36
|
+
const prose = content === undefined ? '' : pageProseHtml(content, ' ');
|
|
32
37
|
return `<noscript>
|
|
33
|
-
<h1>${heading}</h1
|
|
38
|
+
<h1>${heading}</h1>${prose}
|
|
34
39
|
<p>${intro}</p>${pageList(options.routes, mount, hrefs, ' ')}${familyList(site.id, options.ecosystem)}
|
|
35
40
|
</noscript>`;
|
|
36
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noscript.js","sourceRoot":"","sources":["../../../src/seo/core/noscript.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"noscript.js","sourceRoot":"","sources":["../../../src/seo/core/noscript.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGzE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAyF1D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAAC,OAAwB;IACpD,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,UAAU,CAAC;IAC1C,MAAM,KAAK,GAAG,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/D,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAChC,6EAA6E;IAC7E,gEAAgE;IAChE,MAAM,OAAO,GAAG,U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AS,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACnD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAC;IACzC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7C,IAAI,IAAI,CAAC,EAAE,KAAK,OAAO;YAAE,SAAS;QAClC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjE,KAAK,CAAC,IAAI,CACR,oBAAoB,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,OAAO,OAAO,CAClG,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAClC,OAAO;;;EAGP,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QACV,CAAC;AACT,CAAC;AAED,SAAS,WAAW,CAClB,KAAoC;IAEpC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,eAAe,CAAC;IAChD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* carries none of its own, so this only ever writes — see `./template.ts`.
|
|
13
13
|
*/
|
|
14
14
|
import type { SiteId, SiteRecord } from '../../ecosystem/core/sites.ts';
|
|
15
|
+
import type { Language } from '../../i18n/core/languages.ts';
|
|
15
16
|
import type { DocumentMeta } from './documentMeta.ts';
|
|
16
17
|
import type { RouteMeta } from './routes.ts';
|
|
17
18
|
/** Which site is being served, and what it answers. */
|
|
@@ -40,6 +41,17 @@ export interface PageMetaOptions {
|
|
|
40
41
|
* @default '/og.png'
|
|
41
42
|
*/
|
|
42
43
|
image?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Every language the site is written in, the default one included.
|
|
46
|
+
*
|
|
47
|
+
* The language is read off the address — `/fr/tutorial` is the French
|
|
48
|
+
* tutorial — so the canonical, the card and the `hreflang` set are written
|
|
49
|
+
* for the page actually being served, and the routes passed are the table in
|
|
50
|
+
* that language. A site writing one language leaves this out and nothing
|
|
51
|
+
* about its head changes.
|
|
52
|
+
* @default [the default language]
|
|
53
|
+
*/
|
|
54
|
+
languages?: readonly Language[];
|
|
43
55
|
}
|
|
44
56
|
/**
|
|
45
57
|
* Give a page the title, the description and the canonical address of the route
|
|
@@ -73,4 +85,15 @@ export declare function pageHeadTags(options: PageMetaOptions): string;
|
|
|
73
85
|
* not an absolute address.
|
|
74
86
|
*/
|
|
75
87
|
export declare function pageDocumentMeta(options: PageMetaOptions): Required<DocumentMeta>;
|
|
88
|
+
/**
|
|
89
|
+
* The language an address is being served in.
|
|
90
|
+
*
|
|
91
|
+
* Read off the address itself rather than passed beside it, so the catalog a
|
|
92
|
+
* server picks and the canonical it writes cannot disagree.
|
|
93
|
+
* @param options - Which site, which address, and the languages it speaks.
|
|
94
|
+
* @returns The language named by the address, or the default one.
|
|
95
|
+
* @throws {Error} When the deployment names an origin that is not an absolute
|
|
96
|
+
* address.
|
|
97
|
+
*/
|
|
98
|
+
export declare function pageLanguage(options: PageMetaOptions): Language;
|
|
76
99
|
//# sourceMappingURL=pageMeta.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pageMeta.d.ts","sourceRoot":"","sources":["../../../src/seo/core/pageMeta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"pageMeta.d.ts","sourceRoot":"","sources":["../../../src/seo/core/pageMeta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAW7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAQ7C,uDAAuD;AACvD,MAAM,WAAW,eAAe;IAC9B,iCAAiC;IACjC,IAAI,EAAE,UAAU,GAAG,MAAM,CAAC;IAC1B,qEAAqE;IACrE,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IAC7B;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;CACjC;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,MAAM,CAE7E;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAmC7D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,eAAe,GACvB,QAAQ,CAAC,YAAY,CAAC,CAQxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,QAAQ,CAE/D"}
|
package/lib/seo/core/pageMeta.js
CHANGED
|
@@ -12,10 +12,17 @@
|
|
|
12
12
|
* carries none of its own, so this only ever writes — see `./template.ts`.
|
|
13
13
|
*/
|
|
14
14
|
import { siteDisplayName } from "../../ecosystem/core/lookup.js";
|
|
15
|
+
import { DEFAULT_LANGUAGE } from "../../i18n/core/languages.js";
|
|
16
|
+
import { readLanguagePath, withLanguagePath, } from "../../language/core/languagePath.js";
|
|
17
|
+
import { withoutQueryOrFragment } from "../../router/core/address.js";
|
|
18
|
+
import { stripBasePath } from "../../router/core/basePath.js";
|
|
15
19
|
import { escapeAttribute, escapeText } from "../../share/core/escape.js";
|
|
20
|
+
import { alternateLinkTags } from "./alternates.js";
|
|
16
21
|
import { pageMetaFor } from "./routes.js";
|
|
17
22
|
import { mountPathOf, originOf, resolveSite } from "./siteFiles.js";
|
|
18
23
|
import { PAGE_HEAD_MARKER, fill } from "./template.js";
|
|
24
|
+
// A scheme and an authority: what `location.href` hands out.
|
|
25
|
+
const ABSOLUTE_URL = /^[a-z][\d+.a-z-]*:\/\//i;
|
|
19
26
|
/**
|
|
20
27
|
* Give a page the title, the description and the canonical address of the route
|
|
21
28
|
* it answers, plus the card a link to it unfurls into.
|
|
@@ -39,11 +46,24 @@ export function injectPageMeta(html, options) {
|
|
|
39
46
|
*/
|
|
40
47
|
export function pageHeadTags(options) {
|
|
41
48
|
const name = siteDisplayName(resolveSite(options.site));
|
|
42
|
-
const
|
|
49
|
+
const route = routeMetaOf(options);
|
|
50
|
+
const description = route.description;
|
|
43
51
|
const origin = originOf(options);
|
|
44
52
|
const { title, canonical } = pageDocumentMeta(options);
|
|
45
53
|
const image = absolute(options.image ?? '/og.png', origin);
|
|
54
|
+
const alternates = alternateLinkTags({
|
|
55
|
+
origin,
|
|
56
|
+
path: route.path,
|
|
57
|
+
languages: languagesOf(options),
|
|
58
|
+
});
|
|
59
|
+
// A maintenance screen says so on the page itself. `robots.txt` cannot: it
|
|
60
|
+
// stops the crawl, and an address nobody crawled is still listed from
|
|
61
|
+
// whatever links to it, with no description to show for it.
|
|
62
|
+
const robots = route.indexed === false
|
|
63
|
+
? ['<meta name="robots" content="noindex, nofollow" />']
|
|
64
|
+
: [];
|
|
46
65
|
return [
|
|
66
|
+
...robots,
|
|
47
67
|
`<title>${escapeText(title)}</title>`,
|
|
48
68
|
`<meta name="description" content="${escapeAttribute(description)}" />`,
|
|
49
69
|
`<link rel="canonical" href="${escapeAttribute(canonical)}" />`,
|
|
@@ -54,6 +74,7 @@ export function pageHeadTags(options) {
|
|
|
54
74
|
`<meta property="og:url" content="${escapeAttribute(canonical)}" />`,
|
|
55
75
|
`<meta property="og:image" content="${escapeAttribute(image)}" />`,
|
|
56
76
|
'<meta name="twitter:card" content="summary_large_image" />',
|
|
77
|
+
...(alternates === '' ? [] : [alternates]),
|
|
57
78
|
].join('\n');
|
|
58
79
|
}
|
|
59
80
|
/**
|
|
@@ -73,14 +94,42 @@ export function pageDocumentMeta(options) {
|
|
|
73
94
|
return {
|
|
74
95
|
title: `${meta.title} — ${siteDisplayName(site)}`,
|
|
75
96
|
description: meta.description,
|
|
76
|
-
canonical: `${originOf(options)}${meta.path}`,
|
|
97
|
+
canonical: `${originOf(options)}${withLanguagePath(pageLanguage(options), meta.path)}`,
|
|
77
98
|
};
|
|
78
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* The language an address is being served in.
|
|
102
|
+
*
|
|
103
|
+
* Read off the address itself rather than passed beside it, so the catalog a
|
|
104
|
+
* server picks and the canonical it writes cannot disagree.
|
|
105
|
+
* @param options - Which site, which address, and the languages it speaks.
|
|
106
|
+
* @returns The language named by the address, or the default one.
|
|
107
|
+
* @throws {Error} When the deployment names an origin that is not an absolute
|
|
108
|
+
* address.
|
|
109
|
+
*/
|
|
110
|
+
export function pageLanguage(options) {
|
|
111
|
+
return readLanguagePath(ownPath(options), languagesOf(options)).language;
|
|
112
|
+
}
|
|
79
113
|
// A server behind a mount is handed the address the browser asked for, and the
|
|
80
114
|
// route table is written from the site's own root, so the mount the origin
|
|
81
115
|
// carries is taken off it before the table is read.
|
|
82
116
|
function routeMetaOf(options) {
|
|
83
|
-
|
|
117
|
+
const { path } = readLanguagePath(ownPath(options), languagesOf(options));
|
|
118
|
+
return pageMetaFor(options.routes, path);
|
|
119
|
+
}
|
|
120
|
+
// The address from the site's own root, the mount taken off, with the query
|
|
121
|
+
// string and the fragment gone: what the language prefix is read off. An app
|
|
122
|
+
// handing over `location.href` is answered too, so the one reading serves a
|
|
123
|
+
// server, a build and a click alike.
|
|
124
|
+
function ownPath(options) {
|
|
125
|
+
const url = options.url;
|
|
126
|
+
const path = ABSOLUTE_URL.test(url) && URL.canParse(url)
|
|
127
|
+
? new URL(url).pathname
|
|
128
|
+
: withoutQueryOrFragment(url);
|
|
129
|
+
return stripBasePath(mountPathOf(options), path);
|
|
130
|
+
}
|
|
131
|
+
function languagesOf(options) {
|
|
132
|
+
return options.languages ?? [DEFAULT_LANGUAGE];
|
|
84
133
|
}
|
|
85
134
|
function absolute(target, origin) {
|
|
86
135
|
return target.startsWith('/') ? `${origin}${target}` : target;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pageMeta.js","sourceRoot":"","sources":["../../../src/seo/core/pageMeta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"pageMeta.js","sourceRoot":"","sources":["../../../src/seo/core/pageMeta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EACL,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGpD,OAAO,EAAE,WAAW,E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