@myst-theme/site 0.8.3 → 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.
Files changed (2) hide show
  1. package/package.json +11 -11
  2. 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.8.3",
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.8.3",
21
- "@myst-theme/diagrams": "^0.8.3",
22
- "@myst-theme/frontmatter": "^0.8.3",
23
- "@myst-theme/jupyter": "^0.8.3",
24
- "@myst-theme/providers": "^0.8.3",
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.1.35",
29
- "myst-config": "^1.1.35",
30
- "myst-demo": "^0.8.3",
31
- "myst-spec-ext": "^1.1.35",
32
- "myst-to-react": "^0.8.3",
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/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 getMetaTagsForSite({ title, twitter }: SocialSite): HtmlMetaDescriptor {
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 getMetaTagsForArticle({
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
+ }