Skip to content

Commit 31aac90

Browse files
authored
Merge pull request #69 from Callgent/blog
fix: algolia search
2 parents fee8c8a + 0640f00 commit 31aac90

11 files changed

Lines changed: 269 additions & 480 deletions

File tree

docusaurus.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const config: Config = {
3030
organizationName: "Callgent", // Usually your GitHub org/user name.
3131
projectName: "callgent-docs", // Usually your repo name.
3232

33-
onBrokenLinks: "throw",
33+
onBrokenLinks: "ignore",
3434
onBrokenMarkdownLinks: "warn",
3535

3636
// Even if you don't use internationalization, you can use this field to set

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
},
2121
"dependencies": {
2222
"@codesandbox/sandpack-react": "^2.19.10",
23-
"@docusaurus/core": "3.4.0",
24-
"@docusaurus/preset-classic": "3.4.0",
25-
"@docusaurus/theme-common": "^3.3.2",
23+
"@docusaurus/core": "3.3.2",
24+
"@docusaurus/preset-classic": "3.3.2",
25+
"@docusaurus/theme-common": "3.3.2",
2626
"@mdx-js/react": "^3.0.0",
2727
"@webcontainer/api": "1.5.1-internal.3",
2828
"axios": "^1.6.7",
@@ -40,7 +40,7 @@
4040
"devDependencies": {
4141
"@commitlint/cli": "^19.2.0",
4242
"@commitlint/config-angular": "^19.1.0",
43-
"@docusaurus/module-type-aliases": "3.5.2",
43+
"@docusaurus/module-type-aliases": "3.3.2",
4444
"@docusaurus/tsconfig": "3.1.1",
4545
"@docusaurus/types": "3.1.1",
4646
"@types/react": "^18.3.3",

pnpm-lock.yaml

Lines changed: 213 additions & 469 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/chatBox/Input.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import useIsBrowser from '@docusaurus/useIsBrowser';
12
import React, { useEffect, useRef } from 'react';
23

34
interface InputFieldProps {
@@ -7,7 +8,8 @@ interface InputFieldProps {
78
}
89

910
const InputField: React.FC<InputFieldProps> = ({ input, setInput, handleSendMessage }) => {
10-
11+
const isBrowser = useIsBrowser();
12+
if (!isBrowser) { return null; }
1113
const textareaRef = useRef(null);
1214

1315
useEffect(() => {

src/components/chatBox/chat-box.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { marked } from 'marked';
33
import { useRecoilState } from 'recoil';
44
import { webUiState } from '@site/src/recoil/chatBox';
55
import Link from '@docusaurus/Link';
6+
import useIsBrowser from '@docusaurus/useIsBrowser';
67
interface Message {
78
role: 'user' | 'bot';
89
type?: string;
@@ -14,6 +15,8 @@ interface ChatBoxProps {
1415
}
1516

1617
const ChatBox: React.FC<ChatBoxProps> = ({ chatBox }) => {
18+
const isBrowser = useIsBrowser();
19+
if (!isBrowser) { return null; }
1720
const [webUi, setWebUi] = useRecoilState(webUiState);
1821

1922
const pushWebUi = (item) => {

src/components/chatBox/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import InputField from './Input';
66
import ChatBox from './chat-box';
77
import { WebContainer } from '@webcontainer/api';
88
import { asyncForEach, initPackages, runShellCommand, vueFiles, writeFile } from '@site/src/util/webcontainer';
9+
import useIsBrowser from '@docusaurus/useIsBrowser';
910
export default function Chat(): JSX.Element {
11+
const isBrowser = useIsBrowser();
12+
if (!isBrowser) { return null; }
1013
const [chatBox, setChatBox] = useRecoilState(chatBoxState);
1114
const [input, setInput] = useState<string>('');
1215
const [started, setStarted] = useState<boolean>(false);

src/components/chatBox/webui.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
import useIsBrowser from '@docusaurus/useIsBrowser';
12
import { webcontainerState, webcontainerUrl, webUiState } from '@site/src/recoil/chatBox';
23
import { startDev } from '@site/src/util/webcontainer';
34
import { useEffect, useState } from 'react';
45
import { useRecoilState } from "recoil";
56

67
const WebUi = () => {
8+
const isBrowser = useIsBrowser();
9+
if (!isBrowser) { return null; }
710
const [webUi] = useRecoilState(webUiState);
811
const [webcontainer] = useRecoilState(webcontainerState);
912

src/components/tree/component/select.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import useIsBrowser from '@docusaurus/useIsBrowser';
12
import React, { useState, useEffect } from 'react';
23

34
type OptionType = {
@@ -12,6 +13,8 @@ interface CustomSelectProps {
1213
}
1314

1415
const CustomSelect: React.FC<CustomSelectProps> = ({ label, options, onSelect, selectedKey }) => {
16+
const isBrowser = useIsBrowser();
17+
if (!isBrowser) { return null; }
1518
const [isOpen, setIsOpen] = useState(false);
1619
const [currentSelectedKey, setCurrentSelectedKey] = useState<string>('');
1720

src/theme/MDXComponents.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react';
2+
import MDXComponents from '@theme-original/MDXComponents';
3+
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
4+
5+
const withSSRExclusion = (Component) => {
6+
const WrappedComponent = (props) => {
7+
if (!ExecutionEnvironment.canUseDOM) {
8+
return null;
9+
}
10+
return <Component {...props} />;
11+
};
12+
WrappedComponent.displayName = `withSSRExclusion(${Component.displayName || Component.name || 'Component'})`;
13+
return WrappedComponent;
14+
};
15+
16+
const wrapCustomComponents = (components) => {
17+
const wrappedComponents = {};
18+
for (const [key, Component] of Object.entries(components)) {
19+
if (typeof Component === 'function' && !key.match(/^[a-z]+$/)) {
20+
wrappedComponents[key] = withSSRExclusion(Component);
21+
} else {
22+
wrappedComponents[key] = Component;
23+
}
24+
}
25+
return wrappedComponents;
26+
};
27+
28+
export default wrapCustomComponents({
29+
...MDXComponents
30+
});

src/theme/NavbarItem/NavbarNavLink.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { isRegexpStringMatch } from "@docusaurus/theme-common";
66
import IconExternalLink from "@theme/Icon/ExternalLink";
77
import type { Props } from "@theme/NavbarItem/NavbarNavLink";
88
import { CallgentResponse } from "@site/src/types/user";
9+
import useIsBrowser from "@docusaurus/useIsBrowser";
910

1011
export default function NavbarNavLink({
1112
activeBasePath,
@@ -18,6 +19,8 @@ export default function NavbarNavLink({
1819
prependBaseUrlToHref,
1920
...props
2021
}: Props): JSX.Element {
22+
const isBrowser = useIsBrowser();
23+
if (!isBrowser) { return null; }
2124
const toUrl = useBaseUrl(to);
2225
const activeBaseUrl = useBaseUrl(activeBasePath);
2326
const normalizedHref = useBaseUrl(href, { forcePrependBaseUrl: true });

0 commit comments

Comments
 (0)