- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Adds multi instance and versioning handler to Docusaurus V3 (#683)
Showing
6 changed files
with
1,170 additions
and
364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 4 additions & 112 deletions
116
packages/plugin-docusaurus-v3/src/theme/SearchBar/index.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,120 +1,12 @@ | ||
[data-theme=light] .DocSearch { | ||
--docsearch-muted-color: var(--ifm-color-emphasis-700); | ||
--docsearch-container-background: rgba(94,100,112,.7); | ||
--docsearch-modal-background: var(--ifm-color-secondary-lighter); | ||
--docsearch-searchbox-background: var(--ifm-color-secondary); | ||
--docsearch-searchbox-focus-background: var(--ifm-color-white); | ||
--docsearch-hit-background: var(--ifm-color-white); | ||
--docsearch-footer-background: var(--ifm-color-white) | ||
} | ||
|
||
[data-theme=dark] .DocSearch { | ||
--docsearch-text-color: var(--ifm-font-color-base); | ||
--docsearch-muted-color: var(--ifm-color-secondary-darkest); | ||
--docsearch-container-background: rgba(47,55,69,.7); | ||
--docsearch-modal-background: var(--ifm-background-color); | ||
--docsearch-searchbox-background: var(--ifm-background-color); | ||
--docsearch-searchbox-focus-background: var(--ifm-color-black); | ||
--docsearch-hit-background: var(--ifm-color-emphasis-100); | ||
--docsearch-footer-background: var(--ifm-background-surface-color); | ||
--docsearch-key-gradient: linear-gradient(-26.5deg,var(--ifm-color-emphasis-200) 0%,var(--ifm-color-emphasis-100) 100%) | ||
} | ||
|
||
.DocSearch-Button-Container,.checkboxList_TMoE,.filterCheckbox_IByC,.showcaseFavoriteHeader_INmp { | ||
align-items: center; | ||
display: flex | ||
} | ||
|
||
.DocSearch-Button { | ||
align-items: center; | ||
background: var(--docsearch-searchbox-background); | ||
border: 0; | ||
border-radius: 40px; | ||
color: var(--docsearch-muted-color); | ||
cursor: pointer; | ||
display: flex; | ||
font-weight: 500; | ||
height: 36px; | ||
justify-content: space-between; | ||
padding: 0 8px; | ||
-webkit-user-select: none; | ||
user-select: none | ||
} | ||
|
||
.DocSearch-Button:active,.DocSearch-Button:focus,.DocSearch-Button:hover { | ||
background: var(--docsearch-searchbox-focus-background); | ||
box-shadow: var(--docsearch-searchbox-shadow); | ||
color: var(--docsearch-text-color); | ||
outline: 0 | ||
} | ||
|
||
.DocSearch-Search-Icon { | ||
stroke-width: 1.6 | ||
} | ||
|
||
.DocSearch-Button .DocSearch-Search-Icon { | ||
color: var(--docsearch-text-color) | ||
} | ||
|
||
.DocSearch-Button-Placeholder { | ||
font-size: 1rem; | ||
padding: 0 12px 0 6px | ||
} | ||
|
||
.DocSearch-Input,.DocSearch-Link { | ||
-webkit-appearance: none; | ||
font: inherit | ||
} | ||
|
||
.DocSearch-Button-Keys { | ||
display: flex; | ||
min-width: calc(40px + .8em) | ||
} | ||
|
||
[data-theme=light] .DocSearch-Button-Key { | ||
align-items: center; | ||
background: #fff; | ||
.DocSearch-Button kbd { | ||
border: 0; | ||
border-radius: 3px; | ||
box-shadow: #cdcdcd 0px 3px 6px 0px; | ||
color: var(--docsearch-muted-color); | ||
display: flex; | ||
height: 18px; | ||
justify-content: center; | ||
margin-right: 0.4em; | ||
padding: 0 0 2px; | ||
position: relative; | ||
top: -1px; | ||
width: 20px; | ||
} | ||
|
||
[data-theme=dark] .DocSearch-Button-Key { | ||
align-items: center; | ||
background: #4b4b4b; | ||
border: 0; | ||
border-radius: 3px; | ||
box-shadow: var(--docsearch-key-shadow); | ||
color: var(--docsearch-muted-color); | ||
display: flex; | ||
height: 18px; | ||
justify-content: center; | ||
margin-right: 0.4em; | ||
padding: 0 0 2px; | ||
position: relative; | ||
top: -1px; | ||
width: 20px; | ||
} | ||
|
||
.DocSearch--active { | ||
overflow: hidden!important | ||
} | ||
|
||
.DocSearch-Container { | ||
background-color: var(--docsearch-container-background); | ||
height: 100vh; | ||
left: 0; | ||
position: fixed; | ||
top: 0; | ||
width: 100vw; | ||
z-index: 200 | ||
box-shadow: none; | ||
font-size: .8rem !important; | ||
padding: 0 !important; | ||
} |
179 changes: 82 additions & 97 deletions
179
packages/plugin-docusaurus-v3/src/theme/SearchBar/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
export const restFetcher = async <T = unknown>(url: string, options?: any): Promise<T> => { | ||
const response = await fetch(url, options) | ||
|
||
if (response.status === 0) { | ||
throw new Error(`Request failed (network error): ${await response.text()}`) | ||
} else if (response.status >= 400) { | ||
const error = new Error(`Request failed (HTTP error ${response.status})}`) | ||
|
||
;(error as any).response = response | ||
|
||
throw error | ||
} | ||
|
||
return await response.json() | ||
} | ||
|
||
export const postFetcher = async <T = unknown>(url: string, body: any, headers?: any): Promise<T> => { | ||
return await restFetcher(url, { | ||
method: 'POST', | ||
headers: { | ||
...headers, | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify(body) | ||
}) | ||
} | ||
|
||
export async function loggedOperation(preMessage: string, fn: () => Promise<any>, postMessage: string) { | ||
if (preMessage != null) { | ||
console.debug(preMessage) | ||
} | ||
|
||
try { | ||
const response = await fn() | ||
|
||
if (postMessage != null) { | ||
console.debug(postMessage) | ||
} | ||
|
||
return response | ||
} catch (error: any) { | ||
throw new Error(`Error: ${error.message}`) | ||
} | ||
} | ||
|
||
export async function checkIndexAccess(baseUrl: string, APIKey: string, indexId: string) { | ||
const result = await loggedOperation( | ||
'Start: Check index access', | ||
async () => await restFetcher( | ||
`${baseUrl}/api/v1/indexes/get-index?id=${indexId}`, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${APIKey}` | ||
} | ||
} | ||
), | ||
'End: Check index access (success)' | ||
) | ||
|
||
return { endpoint: result?.api_endpoint, api_key: result?.api_key } | ||
} | ||
|
||
export async function createSnapshot(baseUrl: string, APIKey: string, indexId: string, documents: any[]) { | ||
await loggedOperation( | ||
'Start: Create snapshot', | ||
async () => | ||
await postFetcher( | ||
`${baseUrl}/api/v1/webhooks/${indexId}/snapshot`, | ||
documents, | ||
{ | ||
Authorization: `Bearer ${APIKey}` | ||
} | ||
), | ||
'End: Create snapshot (success)' | ||
) | ||
} | ||
|
||
export async function deployIndex(baseUrl: string, APIKey: string, indexId: string) { | ||
await loggedOperation( | ||
'Start: Deploy index', | ||
async () => | ||
await postFetcher( | ||
`${baseUrl}/api/v1/webhooks/${indexId}/deploy`, | ||
{}, | ||
{ | ||
Authorization: `Bearer ${APIKey}` | ||
} | ||
), | ||
'End: Deploy index (success)' | ||
) | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.