Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Algolia docs search #3378

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions aries-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"main": "src/pages/index.js",
"private": true,
"dependencies": {
"@docsearch/react": "^3.4.0",
"@mdx-js/loader": "^1.6.1",
"@next/mdx": "^9.4.4",
"aries-core": "*",
Expand Down
1 change: 1 addition & 0 deletions aries-site/public/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion aries-site/src/components/seo/Meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const Meta = ({
const pageContent = 'products';
const csp = `default-src 'self' 'unsafe-eval';
style-src 'self' *.hpe.com/hfws-static/5/css/ 'unsafe-inline';
connect-src 'self' *.githubusercontent.com/grommet/hpe-design-system/ https://www.google-analytics.com https://www.github.com/grommet/ https://eyes.applitools.com *.hpe.com/hpe/api/ https://ca1.qualtrics.com/API/v3/surveys/ https://api.spacexdata.com/;
connect-src 'self' *.githubusercontent.com/grommet/hpe-design-system/ https://www.google-analytics.com https://www.github.com/grommet/ https://eyes.applitools.com *.hpe.com/hpe/api/ https://ca1.qualtrics.com/API/v3/surveys/ https://api.spacexdata.com/ *.algolianet.com/1/indexes/*/;
media-src 'self' https://d3hq6blov2iije.cloudfront.net/media/;
img-src 'self' data: https://www.google-analytics.com https://images.unsplash.com/ http://s.gravatar.com/avatar/ *.hpe.com/hfws-static/5/ https://d3hq6blov2iije.cloudfront.net/images/textures/ https://d3hq6blov2iije.cloudfront.net/images/gradients/ https://d3hq6blov2iije.cloudfront.net/images/hpe-greenlake/;
script-src 'self' *.hpe.com https://www.google-analytics.com/analytics.js https://netlify-cdp-loader.netlify.app/netlify.js ${
Expand Down
15 changes: 6 additions & 9 deletions aries-site/src/layouts/main/Header.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import React, { useContext, useState } from 'react';
import React, { useContext } from 'react';
import Link from 'next/link';
import { useRouter } from 'next/router';
import { Box, Button, Header, ResponsiveContext } from 'grommet';
import { Search as SearchIcon } from 'grommet-icons';
import { DocSearch } from '@docsearch/react';
import { ThemeModeToggle, AppIdentity } from '../../components';

import { getPageDetails, nameToPath } from '../../utils';
import { Search } from '../navigation';

const StyledHeader = ({ ...rest }) => {
const pageDetails = getPageDetails('Home');
const navItems = pageDetails.pages.map(topic => getPageDetails(topic));
const [showSearch, setShowSearch] = useState(false);
const size = useContext(ResponsiveContext);
const router = useRouter();

Expand All @@ -36,12 +34,11 @@ const StyledHeader = ({ ...rest }) => {
/>
</Link>
))}
<Button
id="search-button"
icon={<SearchIcon />}
onClick={() => setShowSearch(true)}
<DocSearch
appId={process.env.NEXT_PUBLIC_ALGOLIA_APP_ID}
indexName={process.env.NEXT_PUBLIC_ALGOLIA_INDEX_NAME}
apiKey={process.env.NEXT_PUBLIC_ALGOLIA_SEARCH_API_KEY}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When viewing the site in dark mode, this search icon color shows up as a dark grey instead of white
Screen Shot 2023-06-01 at 3 59 01 PM

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good note -- I didn't touch any dark mode styling yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added dark mode styling.

/>
{showSearch && <Search setOpen={setShowSearch} />}
<ThemeModeToggle />
</Box>
</Header>
Expand Down
1 change: 1 addition & 0 deletions aries-site/src/pages/_document.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default class MyDocument extends Document {
async=""
src="https://storage.googleapis.com/hpe-global-header-assets/hpe-global-header.js"
/>
<link rel="stylesheet" href="/style.css" />
</Head>
<body>
<div id="header" className="header" />
Expand Down
Loading