@myst-theme/site 0.8.2 → 0.9.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/package.json +11 -11
- package/src/pages/Root.tsx +4 -1
- package/src/seo/meta.ts +63 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myst-theme/site",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -17,19 +17,19 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@headlessui/react": "^1.7.15",
|
|
19
19
|
"@heroicons/react": "^2.0.18",
|
|
20
|
-
"@myst-theme/common": "^0.
|
|
21
|
-
"@myst-theme/diagrams": "^0.
|
|
22
|
-
"@myst-theme/frontmatter": "^0.
|
|
23
|
-
"@myst-theme/jupyter": "^0.
|
|
24
|
-
"@myst-theme/providers": "^0.
|
|
20
|
+
"@myst-theme/common": "^0.9.0",
|
|
21
|
+
"@myst-theme/diagrams": "^0.9.0",
|
|
22
|
+
"@myst-theme/frontmatter": "^0.9.0",
|
|
23
|
+
"@myst-theme/jupyter": "^0.9.0",
|
|
24
|
+
"@myst-theme/providers": "^0.9.0",
|
|
25
25
|
"@radix-ui/react-collapsible": "^1.0.3",
|
|
26
26
|
"classnames": "^2.3.2",
|
|
27
27
|
"lodash.throttle": "^4.1.1",
|
|
28
|
-
"myst-common": "^1.
|
|
29
|
-
"myst-config": "^1.
|
|
30
|
-
"myst-demo": "^0.
|
|
31
|
-
"myst-spec-ext": "^1.
|
|
32
|
-
"myst-to-react": "^0.
|
|
28
|
+
"myst-common": "^1.3.0",
|
|
29
|
+
"myst-config": "^1.3.0",
|
|
30
|
+
"myst-demo": "^0.9.0",
|
|
31
|
+
"myst-spec-ext": "^1.3.0",
|
|
32
|
+
"myst-to-react": "^0.9.0",
|
|
33
33
|
"nbtx": "^0.2.3",
|
|
34
34
|
"node-cache": "^5.1.2",
|
|
35
35
|
"node-fetch": "^2.6.11",
|
package/src/pages/Root.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SiteManifest } from 'myst-config';
|
|
2
2
|
import type { SiteLoader } from '@myst-theme/common';
|
|
3
|
+
import type { NodeRenderer } from '@myst-theme/providers';
|
|
3
4
|
import { BaseUrlProvider, SiteProvider, Theme, ThemeProvider } from '@myst-theme/providers';
|
|
4
5
|
import {
|
|
5
6
|
Links,
|
|
@@ -12,7 +13,7 @@ import {
|
|
|
12
13
|
Link,
|
|
13
14
|
NavLink,
|
|
14
15
|
} from '@remix-run/react';
|
|
15
|
-
import { DEFAULT_NAV_HEIGHT, renderers } from '../components/index.js';
|
|
16
|
+
import { DEFAULT_NAV_HEIGHT, renderers as defaultRenderers } from '../components/index.js';
|
|
16
17
|
import { Analytics } from '../seo/index.js';
|
|
17
18
|
import { Error404 } from './Error404.js';
|
|
18
19
|
import classNames from 'classnames';
|
|
@@ -26,6 +27,7 @@ export function Document({
|
|
|
26
27
|
staticBuild,
|
|
27
28
|
baseurl,
|
|
28
29
|
top = DEFAULT_NAV_HEIGHT,
|
|
30
|
+
renderers = defaultRenderers,
|
|
29
31
|
}: {
|
|
30
32
|
children: React.ReactNode;
|
|
31
33
|
scripts?: React.ReactNode;
|
|
@@ -35,6 +37,7 @@ export function Document({
|
|
|
35
37
|
staticBuild?: boolean;
|
|
36
38
|
baseurl?: string;
|
|
37
39
|
top?: number;
|
|
40
|
+
renderers?: Record<string, NodeRenderer>;
|
|
38
41
|
}) {
|
|
39
42
|
const links = staticBuild
|
|
40
43
|
? {
|
package/src/seo/meta.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { HtmlMetaDescriptor } from '@remix-run/react';
|
|
1
|
+
import type { HtmlMetaDescriptor, V2_MetaDescriptor } from '@remix-run/react';
|
|
2
2
|
|
|
3
3
|
type SocialSite = {
|
|
4
4
|
title: string;
|
|
5
|
+
description?: string;
|
|
5
6
|
twitter?: string;
|
|
6
7
|
};
|
|
7
8
|
|
|
@@ -20,15 +21,38 @@ function allDefined(meta: Record<string, string | null | undefined>): HtmlMetaDe
|
|
|
20
21
|
return Object.fromEntries(Object.entries(meta).filter(([, v]) => v)) as HtmlMetaDescriptor;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
export function
|
|
24
|
+
export function getMetaTagsForSite_V1({
|
|
25
|
+
title,
|
|
26
|
+
description,
|
|
27
|
+
twitter,
|
|
28
|
+
}: SocialSite): HtmlMetaDescriptor {
|
|
24
29
|
const meta = {
|
|
25
30
|
title,
|
|
31
|
+
description,
|
|
26
32
|
'twitter:site': twitter ? `@${twitter.replace('@', '')}` : undefined,
|
|
27
33
|
};
|
|
28
34
|
return allDefined(meta);
|
|
29
35
|
}
|
|
30
36
|
|
|
31
|
-
export function
|
|
37
|
+
export function getMetaTagsForSite({
|
|
38
|
+
title,
|
|
39
|
+
description,
|
|
40
|
+
twitter,
|
|
41
|
+
}: SocialSite): V2_MetaDescriptor[] {
|
|
42
|
+
const meta: V2_MetaDescriptor[] = [
|
|
43
|
+
{ title },
|
|
44
|
+
{ property: 'og:title', content: title },
|
|
45
|
+
{ name: 'generator', content: 'mystmd' },
|
|
46
|
+
];
|
|
47
|
+
if (description) {
|
|
48
|
+
meta.push({ name: 'description', content: description });
|
|
49
|
+
meta.push({ property: 'og:description', content: description });
|
|
50
|
+
}
|
|
51
|
+
if (twitter) meta.push({ name: 'twitter:site', content: `@${twitter.replace('@', '')}` });
|
|
52
|
+
return meta;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function getMetaTagsForArticle_V1({
|
|
32
56
|
origin,
|
|
33
57
|
url,
|
|
34
58
|
title,
|
|
@@ -55,3 +79,39 @@ export function getMetaTagsForArticle({
|
|
|
55
79
|
};
|
|
56
80
|
return allDefined(meta);
|
|
57
81
|
}
|
|
82
|
+
|
|
83
|
+
export function getMetaTagsForArticle({
|
|
84
|
+
origin,
|
|
85
|
+
url,
|
|
86
|
+
title,
|
|
87
|
+
description,
|
|
88
|
+
image,
|
|
89
|
+
twitter,
|
|
90
|
+
keywords,
|
|
91
|
+
}: SocialArticle): V2_MetaDescriptor[] {
|
|
92
|
+
const meta: V2_MetaDescriptor[] = [
|
|
93
|
+
{ title },
|
|
94
|
+
{ property: 'og:title', content: title },
|
|
95
|
+
{ name: 'generator', content: 'mystmd' },
|
|
96
|
+
];
|
|
97
|
+
if (description) {
|
|
98
|
+
meta.push({ name: 'description', content: description });
|
|
99
|
+
meta.push({ property: 'og:description', content: description });
|
|
100
|
+
}
|
|
101
|
+
if (keywords) meta.push({ name: 'keywords', content: keywords.join(', ') });
|
|
102
|
+
if (origin && url) meta.push({ property: 'og:url', content: `${origin}${url}` });
|
|
103
|
+
if (image) {
|
|
104
|
+
meta.push({ name: 'image', content: image });
|
|
105
|
+
meta.push({ property: 'og:image', content: image });
|
|
106
|
+
}
|
|
107
|
+
if (twitter) {
|
|
108
|
+
meta.push({ name: 'twitter:card', content: image ? 'summary_large_image' : 'summary' });
|
|
109
|
+
meta.push({ name: 'twitter:creator', content: `@${twitter.replace('@', '')}` });
|
|
110
|
+
meta.push({ name: 'twitter:title', content: title });
|
|
111
|
+
if (description) meta.push({ name: 'twitter:description', content: description });
|
|
112
|
+
if (image) meta.push({ name: 'twitter:image', content: image });
|
|
113
|
+
meta.push({ name: 'twitter:alt', content: title });
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return meta;
|
|
117
|
+
}
|