Skip to content

Commit 03d8909

Browse files
committed
Move all manifest ref docs into sub-dir, refactor React component used to render raw HTML
1 parent ba02c38 commit 03d8909

File tree

7 files changed

+4250
-5227
lines changed

7 files changed

+4250
-5227
lines changed
File renamed without changes.
File renamed without changes.

docs/manifest/manifest-ref.js renamed to docs/manifest/json-ref/manifest-ref.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
11
import BrowserOnly from '@docusaurus/BrowserOnly';
22
import React, { useEffect, useRef, useState } from 'react';
33
import './cai-addon.css';
4-
const referenceCAI = require('!!raw-loader!./reference-cai.html')?.default;
54

6-
const ManifestReference = () => {
5+
// Import all possible HTML files statically
6+
const htmlFiles = {
7+
'./reference-cai.html': require('!!raw-loader!./reference-cai.html')?.default,
8+
// Add other HTML files here as needed
9+
};
10+
11+
const ManifestReference = ({ htmlPath }) => {
712
const myRef = useRef(null);
813
const [refAquired, setRefAquired] = useState(false);
14+
const [htmlContent, setHtmlContent] = useState('');
15+
916
useEffect(() => {
1017
setRefAquired(true);
1118
}, []);
1219

20+
useEffect(() => {
21+
// Get the HTML content from our static imports
22+
const content = htmlFiles[htmlPath];
23+
if (content) {
24+
setHtmlContent(content);
25+
} else {
26+
console.error(`HTML file not found: ${htmlPath}`);
27+
setHtmlContent('<div>Error: HTML file not found</div>');
28+
}
29+
}, [htmlPath]);
30+
1331
useEffect(() => {
1432
if (myRef.current) {
1533
for (const link of myRef.current.querySelectorAll('a')) {
@@ -21,12 +39,12 @@ const ManifestReference = () => {
2139
}
2240
}
2341
}
24-
}, [refAquired]);
42+
}, [refAquired, htmlContent]);
2543

2644
return (
2745
<BrowserOnly>
2846
{() => (
29-
<div ref={myRef} dangerouslySetInnerHTML={{ __html: referenceCAI }} />
47+
<div ref={myRef} dangerouslySetInnerHTML={{ __html: htmlContent }} />
3048
)}
3149
</BrowserOnly>
3250
);

docs/manifest/manifest-ref.mdx renamed to docs/manifest/json-ref/manifest-ref.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ import ManifestReference from './manifest-ref.js';
1010
This is a beta release of this reference. It is a work in progress and may not be accurate or complete.
1111
:::
1212

13-
<ManifestReference />
13+
<ManifestReference htmlPath="./reference-cai.html" />

0 commit comments

Comments
 (0)