Skip to content

Commit

Permalink
feat: add algolia doc search (#48)
Browse files Browse the repository at this point in the history
* feat: add Algolia DocSearch

* fix: don't run build-pulish on PR

* fix: disable analytics

* feat: Add meta tag with CSP
  • Loading branch information
IanKrieger authored Jun 25, 2024
1 parent 0cae8f8 commit 5a6ebf0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- main
pull_request:

jobs:
build-publish:
Expand All @@ -27,6 +26,9 @@ jobs:

- name: Build website
run: npm run build
env:
REACT_APP_DOC_SEARCH_APP_ID: ${{ secrets.DOC_SEARCH_APP_ID }}
REACT_APP_DOC_SEARCH_INDEX_NAME: ${{ secrets.DOC_SEARCH_INDEX_NAME }}

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
Expand Down
23 changes: 23 additions & 0 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {themes as prismThemes} from 'prism-react-renderer';
import type {Config} from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';
import * as process from "node:process";

const config: Config = {
title: 'Brave Ads',
Expand All @@ -26,6 +27,16 @@ const config: Config = {
defaultLocale: 'en',
locales: ['en'],
},

headTags: [
{
tagName: 'meta',
attributes: {
'http-equiv': 'Content-Security-Policy',
content: `default-src 'none'; img-src 'self' data:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; base-uri 'none'; form-action 'none'; connect-src https://*.algolia.net https://*.algolianet.com https://*.algolia.io;`,
},
}
],

presets: [
[
Expand Down Expand Up @@ -102,6 +113,18 @@ const config: Config = {
],
copyright: `Copyright © ${new Date().getFullYear()} Brave Software, Inc.`,
},
algolia: {
appId: process.env.REACT_APP_DOC_SEARCH_APP_ID,
// Public API key: it is safe to commit it
apiKey: '9d6bcc3afa8daed9395db8c441bc04a1',
indexName: process.env.REACT_APP_DOC_SEARCH_INDEX_NAME,
// Ensures that search results are relevant to the current language and version
contextualSearch: true,
searchParameters: {
analytics: false,
clickAnalytics: false,
}
},
prism: {
theme: prismThemes.github,
darkTheme: prismThemes.dracula,
Expand Down
22 changes: 11 additions & 11 deletions package-lock.json

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

0 comments on commit 5a6ebf0

Please sign in to comment.