Skip to content

Commit bcef9d7

Browse files
committed
Further fixes
1 parent 9fd72c0 commit bcef9d7

File tree

5 files changed

+86
-39
lines changed

5 files changed

+86
-39
lines changed

docusaurus.config.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,28 @@ const config = {
133133
breadcrumbs: false,
134134
remarkPlugins: [npm2yarnPlugin],
135135
},
136+
pages: {
137+
path: 'src/pages',
138+
routeBasePath: '/',
139+
include: ['**/**.{js,jsx,ts,tsx,md,mdx}'],
140+
exclude: [
141+
'**/_*.{js,jsx,ts,tsx,md,mdx}',
142+
'**/_*/**',
143+
'**/*.test.{js,jsx,ts,tsx}',
144+
'**/__tests__/**',
145+
'**/quick-start/**', // Exclude quick-start directory from pages plugin
146+
],
147+
mdxPageComponent: '@theme/MDXPage',
148+
remarkPlugins: [npm2yarnPlugin],
149+
},
136150
theme: {
137151
customCss: require.resolve('./src/scss/custom.scss'),
138152
},
139153
},
140154
],
141155
],
142156
plugins: [
157+
['./src/plugins/docusaurus-plugin-virtual-files', { rootDir: '.integrationBuilderCache' }],
143158
'docusaurus-plugin-sass',
144159
'./src/plugins/mm-scss-utils',
145160
[
@@ -267,7 +282,6 @@ const config = {
267282
containerId: 'GTM-5FGPLC2Q',
268283
},
269284
],
270-
['./src/plugins/docusaurus-plugin-virtual-files', { rootDir: '.integrationBuilderCache' }],
271285
],
272286
clientModules: [require.resolve('./src/client/scroll-fix.js')],
273287
themeConfig:

src/pages/quick-start/index.tsx

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -47,29 +47,20 @@ const getURLFromBuilderOptions = (opts: Record<string, string>, stepIndex): stri
4747
return url.toString();
4848
};
4949

50-
export default function IntegrationBuilderPage(props: { files?: any }) {
51-
// Get files from props (passed via Docusaurus modules)
52-
const [files, setFiles] = useState<Record<string, string>>({});
53-
const [filesLoaded, setFilesLoaded] = useState(false);
54-
55-
useEffect(() => {
56-
if (props.files) {
57-
try {
58-
// The files should be available directly from props
59-
const filesData = props.files.default || props.files;
60-
console.log('Loaded files from props, count:', Object.keys(filesData).length);
61-
setFiles(filesData);
62-
setFilesLoaded(true);
63-
} catch (error) {
64-
console.error('Error accessing files from props:', error);
65-
setFiles({});
66-
setFilesLoaded(true);
67-
}
68-
} else {
69-
console.log('No files found in props');
70-
setFilesLoaded(true);
71-
}
72-
}, [props.files]);
50+
export default function IntegrationBuilderPage(props: any) {
51+
// Debug what we're actually receiving
52+
console.log('=== DEBUG: Component props ===');
53+
console.log('Full props object:', props);
54+
console.log('Props keys:', Object.keys(props));
55+
console.log('props.files:', props.files);
56+
console.log('props.route:', props.route);
57+
console.log('props.route?.modules:', props.route?.modules);
58+
59+
// Try different ways to access files
60+
const files = props.files || (props.route?.modules?.files ? JSON.parse(props.route.modules.files) : {});
61+
console.log('Extracted files:', files);
62+
console.log('Files is object?', typeof files === 'object');
63+
console.log('Files keys:', Object.keys(files || {}));
7364

7465
const [builderOptions, setBuilderOptions] = useState<Record<string, string>>(
7566
getDefaultBuilderOptions(),
@@ -85,10 +76,10 @@ export default function IntegrationBuilderPage(props: { files?: any }) {
8576
);
8677
const [loading, setLoading] = useState<boolean>(false);
8778
const [initialLoadComplete, setInitialLoadComplete] = useState<boolean>(false);
88-
const integration = useMemo(
89-
() => builder.build(builderOptions, files, stepIndex),
90-
[builderOptions, files, stepIndex],
91-
);
79+
const integration = useMemo(() => {
80+
const result = builder.build(builderOptions, files || {}, stepIndex);
81+
return result;
82+
}, [builderOptions, files, stepIndex]);
9283
const [selectedFilename, setSelectedFilename] = useState(integration.filenames[0] || "");
9384

9485
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
@@ -238,7 +229,7 @@ export default function IntegrationBuilderPage(props: { files?: any }) {
238229
onChange={(event) => onChangeDropdown(key, event.target.value)}
239230
>
240231
{option.choices.map((value) => (
241-
<option value={value.key} key={key}>
232+
<option value={value.key} key={value.key}>
242233
{value.displayName}
243234
</option>
244235
))}

src/pages/quick-start/utils.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ export class ReplaceFileAggregator {
2424
replacementOutcomes = [];
2525

2626
replaceFileVariable(fileContent: string, filename: string, variableName: string, replacement: string): string {
27+
// Add defensive check for undefined/null fileContent
28+
if (!fileContent || typeof fileContent !== 'string') {
29+
console.warn(`Warning: fileContent is ${fileContent} for file ${filename}. Using empty string.`);
30+
return '';
31+
}
32+
2733
// 1. number of new lines to derive OFFSET
2834
const replacementLineCount = replacement.split(`\n`).length - 3;
2935
// 2. line that this occurs on
@@ -47,6 +53,12 @@ export class ReplaceFileAggregator {
4753
fileContent: string,
4854
variableName: string,
4955
): { range: string; filename: string; fileContent: string; variableName: string } {
56+
// Add defensive check for undefined/null fileContent
57+
if (!fileContent || typeof fileContent !== 'string') {
58+
console.warn(`Warning: fileContent is ${fileContent} for file ${filename} in highlightRange. Using empty string.`);
59+
return { range: "1-1", filename, fileContent: "", variableName };
60+
}
61+
5062
const contentByLine = fileContent.split(`\n`);
5163
const startLine = [];
5264
const endLine = [];

src/plugins/docusaurus-plugin-virtual-files/index.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,22 @@ const environment = process.env.IB_ENV || "development";
1010

1111
async function fetchHostedFile(filename) {
1212
try {
13-
console.log(`Fetching file: ${filename}`);
1413
const response = await axios.get("https://raw.githubusercontent.com/" + filename);
1514
var fileContent = response.data;
1615
if (typeof fileContent !== "string") {
1716
fileContent = JSON.stringify(fileContent, null, 2);
1817
}
19-
console.log(`Successfully fetched ${filename}, content length: ${fileContent.length}`);
2018
return fileContent;
2119
} catch (e) {
22-
console.log(`Error fetching ${filename}: ${e}`);
23-
return "";
20+
return ""; // Return empty string as fallback
2421
}
2522
}
2623

2724
const IBfileLinks = require("../../utils/IBfileLinks.json");
2825
module.exports = (context, options) => ({
2926
name: "docusaurus-plugin-virtual-files",
3027
async loadContent() {
28+
console.log('🔄 Virtual files plugin: loadContent called');
3129
const dir = path.resolve(context.siteDir, options.rootDir);
3230
const filenames = Object.values(IBfileLinks);
3331
const fileContents = {};
@@ -42,15 +40,12 @@ module.exports = (context, options) => ({
4240
try {
4341
data = await readFileAsync(filePath, "utf8");
4442
} catch (e) {
45-
console.log(`Fetching ${filename} since local cache not available`);
46-
4743
data = await fetchHostedFile(filename);
4844

4945
try {
5046
await writeFileAsync(filePath, data);
51-
console.log(`Saved ${filename} to cache`);
5247
} catch (error) {
53-
console.log(`Error saving ${filename} to cache`);
48+
console.log(`Error saving ${filename} to cache: ${error.message}`);
5449
}
5550
}
5651
fileContents[filename] = data;
@@ -61,18 +56,38 @@ module.exports = (context, options) => ({
6156
}
6257
}
6358

59+
const emptyFiles = Object.entries(fileContents).filter(([key, value]) => !value || value.length === 0);
60+
if (emptyFiles.length > 0) {
61+
console.log(`Warning: ${emptyFiles.length} files are empty:`, emptyFiles.map(([key]) => key));
62+
}
63+
64+
console.log(`✅ Virtual files plugin: Loaded ${Object.keys(fileContents).length} files`);
6465
return fileContents;
6566
},
6667
async contentLoaded({ content, actions }) {
6768
const { createData, addRoute } = actions;
69+
70+
console.log('🔄 Virtual files plugin: contentLoaded called');
71+
console.log(`📁 Content has ${Object.keys(content).length} files`);
72+
73+
// Create JSON data file like web3auth-docs
6874
const files = await createData("files.json", JSON.stringify(content));
75+
console.log('📄 Created files.json data:', files);
76+
77+
const routePath = "/quick-start";
78+
console.log(`🛣️ Adding route at path: ${routePath}`);
79+
console.log(`📍 Component path: @site/src/pages/quick-start`);
80+
6981
addRoute({
70-
path: (process.env.REACT_APP_BASE_URL || "/docs/") + "quick-start",
82+
path: routePath,
83+
exact: true,
7184
component: "@site/src/pages/quick-start",
7285
modules: {
7386
files,
7487
},
7588
});
89+
90+
console.log('✅ Virtual files plugin: Route added successfully');
7691
},
7792
});
7893

src/theme/Footer/index.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import React, { useEffect } from "react";
1+
import React, { useEffect, useState } from "react";
22
import Footer from "@theme-original/Footer";
33
import { Intercom } from "@intercom/messenger-js-sdk";
44
import useIsBrowser from "@docusaurus/useIsBrowser";
55

66
export default function FooterWrapper(props) {
7+
const [canShowFooter, setCanShowFooter] = useState(true);
8+
79
useEffect(() => {
810
const handleManageCookie = () => {
911
window.Osano.cm.showDrawer("osano-cm-dom-info-dialog-open");
@@ -17,6 +19,17 @@ export default function FooterWrapper(props) {
1719
};
1820
}, []);
1921

22+
useEffect(() => {
23+
if (typeof window !== "undefined") {
24+
// check if footer can be shown
25+
const path = window.location.pathname;
26+
if (path.includes("quick-start")) {
27+
setCanShowFooter(false);
28+
}
29+
}
30+
}, []);
31+
32+
2033
const isBrowser = useIsBrowser();
2134
const isProd = process.env.NODE_ENV === "production";
2235
if (isBrowser && isProd) {
@@ -25,6 +38,8 @@ export default function FooterWrapper(props) {
2538
});
2639
}
2740

41+
if (!canShowFooter) return null;
42+
2843
return (
2944
<>
3045
<Footer {...props} />

0 commit comments

Comments
 (0)