Skip to content

Commit

Permalink
API key patch
Browse files Browse the repository at this point in the history
  • Loading branch information
AE-0h committed Dec 4, 2024
1 parent 0ccaf63 commit 59a6c64
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
3 changes: 2 additions & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const config = {
baseUrl: '/',
customFields: {
keys : {
mendable : process.env.MENDABLE_KEY
mendable : process.env.MENDABLE_KEY,
cookbook: process.env.COOKBOOK_PUBLIC_API_KEY,
},
homePage: {
editUrl: 'https://github.com/rsksmart/devportal/tree/main/',
Expand Down
17 changes: 17 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import SearchBar from '@theme-original/SearchBar';
import AskCookbook from '@cookbookdev/docsbot/react';
import BrowserOnly from '@docusaurus/BrowserOnly';
/** It's a public API key, so it's safe to expose it here */
const COOKBOOK_PUBLIC_API_KEY =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI2NzMyNzg3MDE1OTY2Mzc4MGQ0NTM2MjQiLCJpYXQiOjE3MzEzNjA4ODAsImV4cCI6MjA0NjkzNjg4MH0.RqZAvNBAUcTMNxsGvYLKa-lpGE0s3P3A2PsJB_SoyZE';
export default function SearchBarWrapper(props) {
return (
<>
<SearchBar {...props} />
<BrowserOnly>
{() => <AskCookbook apiKey={COOKBOOK_PUBLIC_API_KEY} />}
</BrowserOnly>
</>
);
}
1 change: 0 additions & 1 deletion src/theme/Navbar/AIButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export default function AIButton() {
const {
siteConfig: {customFields},
} = useDocusaurusContext();

const {keys} = customFields;

const {colorMode} = useColorMode();
Expand Down
16 changes: 10 additions & 6 deletions src/theme/Navbar/AskCookbook/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import React, { Suspense } from "react";
import BrowserOnly from "@docusaurus/BrowserOnly";

/** It's a public API key, so it's safe to expose it here */
const COOKBOOK_PUBLIC_API_KEY =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI2NjU5NmUwZTAwZTliZDQ2MzcwYzMyMzUiLCJpYXQiOjE3MTcxMzY5MTAsImV4cCI6MjAzMjcxMjkxMH0.U6DOhRqbucP5ncR3_LqB_EUHL4kPgFR6sblVkIRl1bc";
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';

const BaseAskCookbook = React.lazy(() =>
import("@cookbookdev/docsbot/react-fixed")
);

export default function AskCookbook() {
const {
siteConfig: {customFields},
} = useDocusaurusContext();
const {keys} = customFields;

const CookbookPubKey = keys.cookbook;

export default function AskCookbook() {
return (
<BrowserOnly>
{() => (
<Suspense>
<BaseAskCookbook apiKey={COOKBOOK_PUBLIC_API_KEY} />
<BaseAskCookbook apiKey={CookbookPubKey} />
</Suspense>
)}
</BrowserOnly>
Expand Down

0 comments on commit 59a6c64

Please sign in to comment.