|
1 | | -import { createToolboxAidHeader } from './index.js'; |
| 1 | +import { mountToolboxAidHeader } from './index.js'; |
2 | 2 |
|
3 | | -const mountRoot = document.getElementById('shared-theme-header-root') || document.getElementById('shared-theme-header'); |
4 | | -if (mountRoot) { |
5 | | - const shell = document.createElement('details'); |
6 | | - shell.className = 'is-collapsible'; |
7 | | - shell.open = true; |
8 | | - |
9 | | - const summary = document.createElement('summary'); |
10 | | - summary.className = 'is-collapsible__summary'; |
11 | | - summary.textContent = 'Header and Intro'; |
12 | | - |
13 | | - const content = document.createElement('div'); |
14 | | - content.className = 'is-collapsible__content'; |
15 | | - |
16 | | - const headerTarget = document.createElement('div'); |
17 | | - headerTarget.id = 'shared-theme-header'; |
18 | | - |
19 | | - const introMain = document.createElement('main'); |
20 | | - introMain.className = 'page-shell'; |
21 | | - |
22 | | - const introSection = document.createElement('section'); |
23 | | - introSection.className = 'page-intro'; |
24 | | - |
25 | | - const introTitle = document.createElement('h1'); |
26 | | - introTitle.className = 'page-intro-title'; |
27 | | - |
28 | | - const introDetails = document.createElement('p'); |
29 | | - introDetails.className = 'page-intro-details'; |
30 | | - |
31 | | - introSection.append(introTitle, introDetails); |
32 | | - introMain.append(introSection); |
33 | | - content.append(headerTarget, introMain); |
34 | | - shell.append(summary, content); |
35 | | - |
36 | | - mountRoot.replaceWith(shell); |
37 | | - |
38 | | - createToolboxAidHeader().then((headerNode) => { |
39 | | - headerTarget.prepend(headerNode); |
40 | | - const body = document.body; |
41 | | - const fallbackTitle = document.querySelector('body > main h1'); |
42 | | - const fallbackDetails = document.querySelector('body > main p'); |
43 | | - const title = body.dataset.headerTitle || fallbackTitle?.textContent?.trim() || ''; |
44 | | - const details = body.dataset.headerDetails || fallbackDetails?.textContent?.trim() || ''; |
45 | | - |
46 | | - introTitle.textContent = title; |
47 | | - introDetails.textContent = details; |
48 | | - }); |
| 3 | +const target = document.getElementById('shared-theme-header'); |
| 4 | +if (target) { |
| 5 | + mountToolboxAidHeader(target); |
49 | 6 | } |
0 commit comments