Skip to content

Commit 46e65f7

Browse files
committed
feat: implement meta in instrument
1 parent 771e8c3 commit 46e65f7

File tree

1 file changed

+20
-7
lines changed
  • packages/react-core/src/components/InteractiveContent

1 file changed

+20
-7
lines changed

packages/react-core/src/components/InteractiveContent/bootstrap.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,28 @@ if (!bundle) {
5151
throw new Error("Failed to get 'data-bundle' attribute from frame element");
5252
}
5353

54+
/** @type {import('@opendatacapture/runtime-core').InteractiveInstrument }*/
5455
const instrument = await evaluateInstrument(bundle);
5556

56-
/** @type {string[] | undefined} */
57+
if (instrument.content.meta) {
58+
Object.entries(instrument.content.meta).forEach(([name, content]) => {
59+
const meta = document.createElement('meta');
60+
meta.name = name;
61+
meta.content = content;
62+
document.head.appendChild(meta);
63+
});
64+
}
65+
66+
const encodedStyle = instrument.content.__injectHead?.style;
67+
if (encodedStyle) {
68+
const style = atob(encodedStyle);
69+
document.head.insertAdjacentHTML('beforeend', `<style>${style}</style>`);
70+
}
71+
72+
if (instrument.content.html) {
73+
document.body.insertAdjacentHTML('beforeend', instrument.content.html);
74+
}
75+
5776
const scripts = instrument.content.__injectHead?.scripts;
5877
scripts?.forEach((encodedScript) => {
5978
const script = document.createElement('script');
@@ -62,10 +81,4 @@ scripts?.forEach((encodedScript) => {
6281
document.head.appendChild(script);
6382
});
6483

65-
const encodedStyle = instrument.content.__injectHead?.style;
66-
if (encodedStyle) {
67-
const style = atob(encodedStyle);
68-
document.head.insertAdjacentHTML('beforeend', `<style>${style}</style>`);
69-
}
70-
7184
await instrument.content.render(done);

0 commit comments

Comments
 (0)