fix(website): fix linting errors
This commit is contained in:
parent
df3e0e1e60
commit
6251f79d7a
17 changed files with 485 additions and 481 deletions
24
.eslintrc.js
24
.eslintrc.js
|
|
@ -50,7 +50,7 @@ module.exports = {
|
|||
{
|
||||
files: ['**/rollup.config.js', 'stories/**/*', '**/__tests__/**'],
|
||||
rules: {
|
||||
'import/no-extraneous-dependencies': 'off',
|
||||
'import/no-extraneous-dependencies': 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -60,15 +60,27 @@ module.exports = {
|
|||
'cypress/globals': true,
|
||||
},
|
||||
rules: {
|
||||
'jest/expect-expect': 'off',
|
||||
'spaced-comment': 'off',
|
||||
'@typescript-eslint/triple-slash-reference': 'off',
|
||||
'jest/expect-expect': 0,
|
||||
'spaced-comment': 0,
|
||||
'@typescript-eslint/triple-slash-reference': 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['scripts/**/*', '*.config.js'],
|
||||
files: [
|
||||
'scripts/**/*',
|
||||
'*.config.js',
|
||||
'packages/website/plugins/**/*',
|
||||
'packages/website/sidebars.js',
|
||||
],
|
||||
rules: {
|
||||
'import/no-commonjs': 'off',
|
||||
'import/no-commonjs': 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['packages/website/**/*'],
|
||||
rules: {
|
||||
'import/no-unresolved': 0,
|
||||
'import/no-extraneous-dependencies': 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
v14.6.0
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
module.exports = {
|
||||
proseWrap: 'always',
|
||||
singleQuote: true,
|
||||
trailingComma: 'es5',
|
||||
};
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
module.exports = function(context, options) {
|
||||
module.exports = function (_context, _options) {
|
||||
return {
|
||||
name: 'loaders',
|
||||
configureWebpack(config, isServer) {
|
||||
configureWebpack(_config, _isServer) {
|
||||
return {
|
||||
module: {
|
||||
rules: [
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
module.exports = function (context, options) {
|
||||
module.exports = function (_context, _options) {
|
||||
return {
|
||||
name: 'postcss-tailwindcss-loader',
|
||||
configureWebpack(config, isServer, utils) {
|
||||
configureWebpack(_config, _isServer, _utils) {
|
||||
return {
|
||||
module: {
|
||||
rules: [
|
||||
|
|
@ -28,7 +28,7 @@ module.exports = function (context, options) {
|
|||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
};
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import React, { useState } from 'react';
|
||||
import {
|
||||
Card,
|
||||
Input,
|
||||
|
|
@ -7,11 +6,12 @@ import {
|
|||
Button,
|
||||
InlineLink,
|
||||
} from '@algolia/ui-library';
|
||||
import useBaseUrl from '@docusaurus/useBaseUrl';
|
||||
|
||||
import { useBaseUrlUtils } from '@docusaurus/useBaseUrl';
|
||||
import useThemeContext from '@theme/hooks/useThemeContext';
|
||||
import React, { useState } from 'react';
|
||||
|
||||
function ApplyForm() {
|
||||
const { withBaseUrl } = useBaseUrlUtils();
|
||||
const theme = useThemeContext.isDarkTheme ? 'dark' : 'light';
|
||||
const [hasSent, setHasSent] = useState(false);
|
||||
const [url, setUrl] = useState('');
|
||||
|
|
@ -25,7 +25,7 @@ function ApplyForm() {
|
|||
const url = applyForm.getAttribute('action');
|
||||
const formData = new FormData(applyForm);
|
||||
const data = {};
|
||||
formData.forEach(function(value, key) {
|
||||
formData.forEach(function (value, key) {
|
||||
data[key] = value;
|
||||
});
|
||||
const body = JSON.stringify(data);
|
||||
|
|
@ -34,7 +34,7 @@ function ApplyForm() {
|
|||
method,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body,
|
||||
}).then(response => {
|
||||
}).then((response) => {
|
||||
if (response.ok) {
|
||||
setHasSent(true);
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ function ApplyForm() {
|
|||
|
||||
<Text aria-label="recommendations">
|
||||
Please be patient, in the meantime, you can implement{' '}
|
||||
<InlineLink href={useBaseUrl('/docs/tips')}>
|
||||
<InlineLink href={withBaseUrl('/docs/tips')}>
|
||||
our recommendations for building a great DocSearch experience.
|
||||
</InlineLink>
|
||||
</Text>
|
||||
|
|
@ -83,7 +83,7 @@ function ApplyForm() {
|
|||
name="url"
|
||||
aria-label="URL of the documentation website"
|
||||
value={url}
|
||||
onChange={event => setUrl(event.target.value)}
|
||||
onChange={(event) => setUrl(event.target.value)}
|
||||
placeholder="https://project.org/docs"
|
||||
required
|
||||
/>
|
||||
|
|
@ -101,7 +101,7 @@ function ApplyForm() {
|
|||
name="email"
|
||||
aria-label="Email address of the owner of this website"
|
||||
value={email}
|
||||
onChange={event => setEmail(event.target.value)}
|
||||
onChange={(event) => setEmail(event.target.value)}
|
||||
placeholder="you@project.org"
|
||||
required
|
||||
/>
|
||||
|
|
@ -123,7 +123,7 @@ function ApplyForm() {
|
|||
required
|
||||
/>
|
||||
I'm the owner of the website and I have{' '}
|
||||
<InlineLink href={useBaseUrl('/docs/who-can-apply')}>
|
||||
<InlineLink href={withBaseUrl('/docs/who-can-apply')}>
|
||||
read the checklist
|
||||
</InlineLink>
|
||||
</LabelText>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React, { useRef, useEffect } from 'react';
|
||||
import Head from '@docusaurus/Head';
|
||||
import React, { useRef, useEffect } from 'react';
|
||||
|
||||
export default function DocSearch({ appId, indexName, apiKey }) {
|
||||
const docsearchRef = useRef(null);
|
||||
|
|
@ -19,7 +19,7 @@ export default function DocSearch({ appId, indexName, apiKey }) {
|
|||
},
|
||||
});
|
||||
});
|
||||
}, [docsearchRef, indexName, apiKey]);
|
||||
}, [docsearchRef, indexName, apiKey, appId]);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import React from 'react';
|
|||
|
||||
export function DocSearchLogo(props) {
|
||||
return (
|
||||
<svg props {...props} viewBox="0 0 476 78" className="docsearch-logo">
|
||||
<svg {...props} viewBox="0 0 476 78" className="docsearch-logo">
|
||||
<g fillRule="nonzero" fill="none">
|
||||
<path
|
||||
d="M36.493 77.289h-33.419c-1.698 0-3.074-1.37-3.074-3.061h36.523c12.769.062 24.6-6.663 31.038-17.642 6.438-10.979 6.504-24.543.174-35.584-6.331-11.041-18.096-17.88-30.865-17.942h-36.87c0-1.69 1.376-3.061 3.074-3.061h33.796c10.31.01 20.193 4.1 27.472 11.369 7.28 7.268 11.36 17.12 11.341 27.384-.059 21.366-17.741 38.536-39.191 38.536z"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
/* eslint-disable eslint-comments/no-unlimited-disable */
|
||||
/* eslint-disable */
|
||||
|
||||
import React from 'react';
|
||||
|
||||
export default class ErrorBoundary extends React.Component {
|
||||
|
|
@ -17,8 +20,8 @@ export default class ErrorBoundary extends React.Component {
|
|||
componentDidCatch(error, info) {
|
||||
this.setState({
|
||||
hasError: true,
|
||||
error: error,
|
||||
info: info,
|
||||
error,
|
||||
info,
|
||||
});
|
||||
}
|
||||
render() {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import React from 'react';
|
||||
import Layout from '@theme/Layout';
|
||||
import { Section, Hero } from '@algolia/ui-library';
|
||||
import useThemeContext from '@theme/hooks/useThemeContext';
|
||||
import Layout from '@theme/Layout';
|
||||
import React from 'react';
|
||||
|
||||
import ApplyForm from '../components/ApplyForm.js';
|
||||
import { DocSearchLogo } from '../components/DocSearchLogo';
|
||||
import useThemeContext from '@theme/hooks/useThemeContext';
|
||||
|
||||
function Apply() {
|
||||
const theme = useThemeContext.isDarkTheme ? 'dark' : 'light';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import Layout from '@theme/Layout';
|
||||
import { useLocation } from 'react-router';
|
||||
import queryString from 'query-string';
|
||||
import {
|
||||
Button,
|
||||
Hero,
|
||||
|
|
@ -10,21 +6,25 @@ import {
|
|||
LabelText,
|
||||
InlineLink,
|
||||
} from '@algolia/ui-library';
|
||||
import DocSearch from '../components/DocSearch';
|
||||
import ErrorBoundary from '../components/ErrorBoundary';
|
||||
import algoliasearch from 'algoliasearch/lite';
|
||||
import Card from '@algolia/ui-library/public/components/Card';
|
||||
import useBaseUrl from '@docusaurus/useBaseUrl';
|
||||
import { LiveProvider, LiveEditor, LiveError, LivePreview } from 'react-live';
|
||||
import { useBaseUrlUtils } from '@docusaurus/useBaseUrl';
|
||||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||
import useThemeContext from '@theme/hooks/useThemeContext';
|
||||
import Layout from '@theme/Layout';
|
||||
import algoliasearch from 'algoliasearch/lite';
|
||||
import github from 'prism-react-renderer/themes/github';
|
||||
import vsDark from 'prism-react-renderer/themes/vsDark';
|
||||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||
import queryString from 'query-string';
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import { LiveProvider, LiveEditor, LiveError, LivePreview } from 'react-live';
|
||||
import { useLocation } from 'react-router';
|
||||
|
||||
import DocSearch from '../components/DocSearch';
|
||||
import { DocSearchLogo } from '../components/DocSearchLogo';
|
||||
|
||||
import useThemeContext from '@theme/hooks/useThemeContext';
|
||||
import ErrorBoundary from '../components/ErrorBoundary';
|
||||
|
||||
function Demo() {
|
||||
const { withBaseUrl } = useBaseUrlUtils();
|
||||
const { siteConfig } = useDocusaurusContext();
|
||||
const theme = useThemeContext.isDarkTheme ? 'dark' : 'light';
|
||||
|
||||
|
|
@ -44,21 +44,22 @@ function Demo() {
|
|||
algoliasearch('DSW01O6QPF', 'e55d03a808bad4e426d28fd4a1a18338')
|
||||
);
|
||||
|
||||
function resetCredentials() {
|
||||
setProjectName(DEFAULT_INDEX_NAME);
|
||||
setIndexName(DEFAULT_INDEX_NAME);
|
||||
setApiKey(DEFAULT_API_KEY);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
function resetCredentials() {
|
||||
setProjectName(DEFAULT_INDEX_NAME);
|
||||
setIndexName(DEFAULT_INDEX_NAME);
|
||||
setApiKey(DEFAULT_API_KEY);
|
||||
}
|
||||
|
||||
const index = searchClient.current.initIndex('live-demo');
|
||||
|
||||
if (!selection && !projectName) {
|
||||
index
|
||||
.search(indexName, {
|
||||
filters: 'status.stage: "Outbound"',
|
||||
hitsPerPage: 1,
|
||||
})
|
||||
.then(result => {
|
||||
.then((result) => {
|
||||
if (result.nbHits === 0) {
|
||||
resetCredentials();
|
||||
} else {
|
||||
|
|
@ -70,7 +71,6 @@ function Demo() {
|
|||
setDocsearchIssueUrl(
|
||||
activeDocSearchIndex.outbound.docsearchIssueUrl
|
||||
);
|
||||
console.log(activeDocSearchIndex.outbound);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
|
|
@ -78,7 +78,7 @@ function Demo() {
|
|||
});
|
||||
setSelection(true);
|
||||
}
|
||||
}, [indexName]);
|
||||
}, [indexName, projectName, selection, DEFAULT_API_KEY, DEFAULT_INDEX_NAME]);
|
||||
|
||||
const code = `<!-- at the end of the \`head\` -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />
|
||||
|
|
@ -136,7 +136,7 @@ function Demo() {
|
|||
<DocSearchLogo width="190px" />
|
||||
<img
|
||||
className="ds-icon-heart"
|
||||
src={useBaseUrl('/img/icons/icon-heart.png')}
|
||||
src={withBaseUrl('/img/icons/icon-heart.png')}
|
||||
width="30px"
|
||||
/>
|
||||
{projectName !== null && <LabelText big>{projectName}</LabelText>}
|
||||
|
|
@ -163,7 +163,7 @@ function Demo() {
|
|||
Thumb up the request to feature DocSearch on the repo 👍{' '}
|
||||
<img
|
||||
className="github__logo"
|
||||
src={useBaseUrl('/img/icons/icon-github.png')}
|
||||
src={withBaseUrl('/img/icons/icon-github.png')}
|
||||
width="30px"
|
||||
alt="GitHub"
|
||||
/>
|
||||
|
|
@ -176,7 +176,7 @@ function Demo() {
|
|||
code={`<input type="text" id="search" placeholder="Search the doc" />`}
|
||||
language="html"
|
||||
noInline={true}
|
||||
transformCode={_code =>
|
||||
transformCode={(_code) =>
|
||||
`class Null extends React.Component {render(){return null}}`
|
||||
}
|
||||
theme={theme === 'dark' ? vsDark : github}
|
||||
|
|
@ -192,7 +192,7 @@ function Demo() {
|
|||
code={code}
|
||||
language="html"
|
||||
noInline={true}
|
||||
transformCode={_code =>
|
||||
transformCode={(_code) =>
|
||||
`class Null extends React.Component {render(){return null}}`
|
||||
}
|
||||
theme={theme === 'dark' ? vsDark : github}
|
||||
|
|
@ -223,7 +223,7 @@ function Demo() {
|
|||
<Button
|
||||
primary
|
||||
style={{ textDecoration: 'none', alignItems: 'center' }}
|
||||
href={useBaseUrl('/apply')}
|
||||
href={withBaseUrl('/apply')}
|
||||
>
|
||||
Join the Program
|
||||
</Button>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,16 +1,15 @@
|
|||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import Layout from '@theme/Layout';
|
||||
import { useLocation } from 'react-router';
|
||||
import queryString from 'query-string';
|
||||
import { Hero, Text, Pill, LabelText } from '@algolia/ui-library';
|
||||
import Card from '@algolia/ui-library/public/components/Card';
|
||||
import useBaseUrl from '@docusaurus/useBaseUrl';
|
||||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||
|
||||
import useThemeContext from '@theme/hooks/useThemeContext';
|
||||
import { DocSearchLogo } from '../components/DocSearchLogo';
|
||||
|
||||
import Layout from '@theme/Layout';
|
||||
import algoliasearch from 'algoliasearch';
|
||||
import queryString from 'query-string';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useLocation } from 'react-router';
|
||||
|
||||
import { DocSearchLogo } from '../components/DocSearchLogo';
|
||||
|
||||
function Inspector() {
|
||||
const { siteConfig } = useDocusaurusContext();
|
||||
|
|
@ -18,10 +17,9 @@ function Inspector() {
|
|||
|
||||
const DEFAULT_INDEX_NAME = siteConfig.themeConfig.algolia.indexName;
|
||||
|
||||
const {
|
||||
indexName: indexNameFromUrl = DEFAULT_INDEX_NAME,
|
||||
} = queryString.parse(useLocation().search);
|
||||
const [indexName, setIndexName] = useState(indexNameFromUrl);
|
||||
const { indexName = DEFAULT_INDEX_NAME } = queryString.parse(
|
||||
useLocation().search
|
||||
);
|
||||
const [record, setIndexRecord] = useState(null);
|
||||
const [objectID, setObjectID] = useState(null);
|
||||
|
||||
|
|
@ -37,7 +35,7 @@ function Inspector() {
|
|||
setIndexRecord(results[0]);
|
||||
});
|
||||
}
|
||||
}, [objectID]);
|
||||
}, [index, objectID]);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
@ -71,7 +69,7 @@ function Inspector() {
|
|||
<input
|
||||
type="text"
|
||||
style={{ margin: '3em 0', height: '2em', width: '80%' }}
|
||||
onChange={e => setObjectID(e.target.value)}
|
||||
onChange={(e) => setObjectID(e.target.value)}
|
||||
/>
|
||||
<br />
|
||||
{record ? <Record record={record}></Record> : null}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
import React, { useState, useEffect } from 'react';
|
||||
import Layout from '@theme/Layout';
|
||||
import { useLocation } from 'react-router';
|
||||
import queryString from 'query-string';
|
||||
import {
|
||||
Button,
|
||||
Hero,
|
||||
|
|
@ -10,16 +6,20 @@ import {
|
|||
LabelText,
|
||||
InlineLink,
|
||||
} from '@algolia/ui-library';
|
||||
import DocSearch from '../components/DocSearch';
|
||||
import ErrorBoundary from '../components/ErrorBoundary';
|
||||
import algoliasearch from 'algoliasearch/lite';
|
||||
import Card from '@algolia/ui-library/public/components/Card';
|
||||
import useBaseUrl from '@docusaurus/useBaseUrl';
|
||||
import { LiveProvider, LiveEditor, LiveError, LivePreview } from 'react-live';
|
||||
import useThemeContext from '@theme/hooks/useThemeContext';
|
||||
import Layout from '@theme/Layout';
|
||||
import algoliasearch from 'algoliasearch/lite';
|
||||
import github from 'prism-react-renderer/themes/github';
|
||||
import vsDark from 'prism-react-renderer/themes/vsDark';
|
||||
import queryString from 'query-string';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { LiveProvider, LiveEditor, LiveError, LivePreview } from 'react-live';
|
||||
import { useLocation } from 'react-router';
|
||||
|
||||
import useThemeContext from '@theme/hooks/useThemeContext';
|
||||
import DocSearch from '../components/DocSearch';
|
||||
import ErrorBoundary from '../components/ErrorBoundary';
|
||||
|
||||
function Landing() {
|
||||
const theme = useThemeContext.isDarkTheme ? 'dark' : 'light';
|
||||
|
|
@ -58,8 +58,8 @@ function Landing() {
|
|||
const index = searchClient.initIndex(indexName);
|
||||
index
|
||||
.search('')
|
||||
.then(_ => setisValidDSCred(true))
|
||||
.catch(_ => {
|
||||
.then((_) => setisValidDSCred(true))
|
||||
.catch((_) => {
|
||||
setWrongCredentials(true);
|
||||
fallbackToDocSearchDocCred();
|
||||
});
|
||||
|
|
@ -106,7 +106,7 @@ function Landing() {
|
|||
code={`<input type="text" id="q" placeholder="Search the doc" />`}
|
||||
language="html"
|
||||
noInline={true}
|
||||
transformCode={code =>
|
||||
transformCode={(_code) =>
|
||||
`class Null extends React.Component {render(){return null}}`
|
||||
}
|
||||
theme={theme === 'dark' ? vsDark : github}
|
||||
|
|
@ -133,7 +133,7 @@ function Landing() {
|
|||
</script>`}
|
||||
language="html"
|
||||
noInline={true}
|
||||
transformCode={code =>
|
||||
transformCode={(_code) =>
|
||||
`class Null extends React.Component {render(){return null}}`
|
||||
}
|
||||
theme={theme === 'dark' ? vsDark : github}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
import React, { useState, useEffect } from 'react';
|
||||
import Layout from '@theme/Layout';
|
||||
import { useLocation } from 'react-router';
|
||||
import queryString from 'query-string';
|
||||
import {
|
||||
Button,
|
||||
Hero,
|
||||
|
|
@ -10,13 +6,17 @@ import {
|
|||
LabelText,
|
||||
InlineLink,
|
||||
} from '@algolia/ui-library';
|
||||
import DocSearch from '../components/DocSearch';
|
||||
import ErrorBoundary from '../components/ErrorBoundary';
|
||||
import algoliasearch from 'algoliasearch/lite';
|
||||
import Card from '@algolia/ui-library/public/components/Card';
|
||||
import useBaseUrl from '@docusaurus/useBaseUrl';
|
||||
|
||||
import useThemeContext from '@theme/hooks/useThemeContext';
|
||||
import Layout from '@theme/Layout';
|
||||
import algoliasearch from 'algoliasearch/lite';
|
||||
import queryString from 'query-string';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useLocation } from 'react-router';
|
||||
|
||||
import DocSearch from '../components/DocSearch';
|
||||
import ErrorBoundary from '../components/ErrorBoundary';
|
||||
|
||||
function Playground() {
|
||||
const theme = useThemeContext.isDarkTheme ? 'dark' : 'light';
|
||||
|
|
@ -55,8 +55,8 @@ function Playground() {
|
|||
const index = searchClient.initIndex(indexName);
|
||||
index
|
||||
.search('')
|
||||
.then(_ => setisValidDSCred(true))
|
||||
.catch(_ => {
|
||||
.then((_) => setisValidDSCred(true))
|
||||
.catch((_) => {
|
||||
setWrongCredentials(true);
|
||||
fallbackToDocSearchDocCred();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
import React, { useState, useEffect } from 'react';
|
||||
import { useLocation } from 'react-router';
|
||||
import queryString from 'query-string';
|
||||
import Layout from '@theme/Layout';
|
||||
import {
|
||||
Button,
|
||||
Hero,
|
||||
|
|
@ -10,14 +6,20 @@ import {
|
|||
LabelText,
|
||||
InlineLink,
|
||||
} from '@algolia/ui-library';
|
||||
import algoliasearch from 'algoliasearch/lite';
|
||||
import Card from '@algolia/ui-library/public/components/Card';
|
||||
import useBaseUrl from '@docusaurus/useBaseUrl';
|
||||
import { DocSearchModal } from '@docsearch/react';
|
||||
import ErrorBoundary from '../components/ErrorBoundary';
|
||||
import { useBaseUrlUtils } from '@docusaurus/useBaseUrl';
|
||||
import useThemeContext from '@theme/hooks/useThemeContext';
|
||||
import Layout from '@theme/Layout';
|
||||
import algoliasearch from 'algoliasearch/lite';
|
||||
import queryString from 'query-string';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useLocation } from 'react-router';
|
||||
|
||||
import ErrorBoundary from '../components/ErrorBoundary';
|
||||
|
||||
function V3Me() {
|
||||
const { withBaseUrl } = useBaseUrlUtils();
|
||||
const theme = useThemeContext.isDarkTheme ? 'dark' : 'light';
|
||||
|
||||
const getParams = queryString.parse(useLocation().search);
|
||||
|
|
@ -27,22 +29,6 @@ function V3Me() {
|
|||
apiKey: apiKeyQS = '',
|
||||
} = getParams;
|
||||
|
||||
const searchParameters = { hitsPerPage: 10 };
|
||||
|
||||
for (const [name, value] of Object.entries(getParams)) {
|
||||
if (name !== 'appId' && name !== 'indexName' && name !== 'apiKey') {
|
||||
const parsedInt = parseInt(value, 10);
|
||||
const parsedBool =
|
||||
value === 'true' ? true : value === 'false' ? false : null;
|
||||
searchParameters[name] =
|
||||
parsedInt !== NaN
|
||||
? parsedInt
|
||||
: parsedBool
|
||||
? parsedBool !== null
|
||||
: value;
|
||||
}
|
||||
}
|
||||
|
||||
const [isValidDSCred, setisValidDSCred] = useState(false);
|
||||
const [wrongCredentials, setWrongCredentials] = useState(false);
|
||||
const [appId, setAppId] = useState(appIdQS);
|
||||
|
|
@ -71,13 +57,29 @@ function V3Me() {
|
|||
const index = searchClient.initIndex(indexName);
|
||||
index
|
||||
.search('')
|
||||
.then(_ => setisValidDSCred(true))
|
||||
.catch(_ => {
|
||||
.then((_) => setisValidDSCred(true))
|
||||
.catch((_) => {
|
||||
setWrongCredentials(true);
|
||||
fallbackToDocSearchDocCred();
|
||||
});
|
||||
}, [appId, indexName, apiKey]);
|
||||
|
||||
const searchParameters = { hitsPerPage: 10 };
|
||||
for (const [name, value] of Object.entries(getParams)) {
|
||||
if (name !== 'appId' && name !== 'indexName' && name !== 'apiKey') {
|
||||
const parsedInt = parseInt(value, 10);
|
||||
const parsedBool =
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
value === 'true' ? true : value === 'false' ? false : null;
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
searchParameters[name] = !isNaN(parsedInt)
|
||||
? parsedInt
|
||||
: parsedBool
|
||||
? parsedBool !== null
|
||||
: value;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Hero background="orbInside" title="V3Me" padding="small" />
|
||||
|
|
@ -117,7 +119,7 @@ function V3Me() {
|
|||
</Text>
|
||||
<Text className="mt-4">
|
||||
<a
|
||||
href={useBaseUrl('/v3me/?indexName=<indexName>&apiKey=<apiKey>')}
|
||||
href={withBaseUrl('/v3me/?indexName=<indexName>&apiKey=<apiKey>')}
|
||||
>{`https://docsearch.algolia.com/v3me/?indexName=<indexName>&apiKey=<apiKey>&appId=<appId>`}</a>
|
||||
</Text>
|
||||
<Text className="mt-4">
|
||||
|
|
@ -145,7 +147,7 @@ function V3Me() {
|
|||
<Button
|
||||
primary
|
||||
style={{ textDecoration: 'none', alignItems: 'center' }}
|
||||
href={useBaseUrl('/apply')}
|
||||
href={withBaseUrl('/apply')}
|
||||
>
|
||||
Join the Program
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@ module.exports = {
|
|||
extend: {},
|
||||
},
|
||||
plugins: [],
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue