@hagicode/hagilight-docusaurus 0.9.7 → 0.9.8

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.
@@ -3,6 +3,10 @@ import { PROMOTO_SHELL_MARKUP } from './promoto-markup.js';
3
3
  const ELEMENT_NAME = 'hagilight-promoto-banner';
4
4
  const DEFAULT_LOCALE = 'en-US';
5
5
  const mounts = new WeakMap();
6
+ function readSiteId(doc) {
7
+ const content = doc.querySelector('meta[name="hagilight-site-id"]')?.getAttribute('content')?.trim();
8
+ return content || undefined;
9
+ }
6
10
  export function mountPromotoBanner(doc, locale) {
7
11
  const footer = doc.querySelector('footer');
8
12
  const previous = mounts.get(doc);
@@ -12,6 +16,9 @@ export function mountPromotoBanner(doc, locale) {
12
16
  const banner = doc.createElement(ELEMENT_NAME);
13
17
  banner.className = 'hagilight-promoto';
14
18
  banner.dataset.locale = locale;
19
+ const siteId = readSiteId(doc);
20
+ if (siteId)
21
+ banner.dataset.siteId = siteId;
15
22
  banner.hidden = true;
16
23
  banner.innerHTML = PROMOTO_SHELL_MARKUP;
17
24
  doc.body.append(banner);
package/dist/index.js CHANGED
@@ -20,6 +20,13 @@ function analyticsHeadTags(options) {
20
20
  ...(options.fiftyOneLaId === undefined ? [] : fiftyOneLaHeadTags(options.fiftyOneLaId)),
21
21
  ];
22
22
  }
23
+ /** Exposes the footer site identifier to the client banner, which tags its call to action with it. */
24
+ function promotoSiteIdHeadTags(options) {
25
+ const siteId = options.links.siteId?.trim();
26
+ if (!options.promoto || !siteId)
27
+ return [];
28
+ return [{ tagName: 'meta', attributes: { name: 'hagilight-site-id', content: siteId } }];
29
+ }
23
30
  function clientModules(options) {
24
31
  const analyticsEnabled = options.googleAnalyticsId !== undefined || options.fiftyOneLaId !== undefined;
25
32
  return [
@@ -81,6 +88,7 @@ function createPlugin(context, options) {
81
88
  ...analyticsHeadTags(options),
82
89
  ...seoHeadTags(options.seo, site),
83
90
  ...feedHeadTags(site, options.rss, feedItems.length),
91
+ ...promotoSiteIdHeadTags(options),
84
92
  ],
85
93
  };
86
94
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hagicode/hagilight-docusaurus",
3
- "version": "0.9.7",
3
+ "version": "0.9.8",
4
4
  "type": "module",
5
5
  "description": "Docusaurus plugin for HagiCode site features: footer, analytics, promote card, locales, SEO, sitemap, robots.txt, and RSS",
6
6
  "repository": {
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "@docusaurus/types": "^3.9.2",
41
- "@hagicode/hagilight-core": "0.9.7"
41
+ "@hagicode/hagilight-core": "0.9.8"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@docusaurus/core": "^3.9.2",