From 74fefe81799c3b4e9ada649dc20ac1a4856f8fc4 Mon Sep 17 00:00:00 2001 From: Ian Krieger Date: Fri, 14 Jun 2024 15:24:52 -0400 Subject: [PATCH 1/4] feat: add Algolia DocSearch --- .github/workflows/gh-pages.yml | 3 +++ docusaurus.config.ts | 9 +++++++++ package-lock.json | 22 +++++++++++----------- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index c7c7a9e0..212bd186 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -27,6 +27,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 diff --git a/docusaurus.config.ts b/docusaurus.config.ts index bc2ef4c1..aa511629 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -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', @@ -102,6 +103,14 @@ 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, + }, prism: { theme: prismThemes.github, darkTheme: prismThemes.dracula, diff --git a/package-lock.json b/package-lock.json index 2d2233cf..2c80fa38 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5806,9 +5806,9 @@ "integrity": "sha512-cXLGjP0c4T3flZJKQSuziYoq7MlT+rnvfZjfp7h+I7K9BNX54kP9nyWvdbwjQ4u1iWbOL4u96fgeZLToQlZC7w==" }, "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", + "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", "engines": { "node": ">=6" } @@ -10857,9 +10857,9 @@ } }, "node_modules/picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz", + "integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==" }, "node_modules/picomatch": { "version": "2.3.1", @@ -13766,9 +13766,9 @@ } }, "node_modules/update-browserslist-db": { - "version": "1.0.13", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", - "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==", + "version": "1.0.16", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.16.tgz", + "integrity": "sha512-KVbTxlBYlckhF5wgfyZXTWnMn7MMZjMu9XG8bPlliUOP9ThaF4QnhP8qrjrH7DRzHfSk0oQv1wToW+iA5GajEQ==", "funding": [ { "type": "opencollective", @@ -13784,8 +13784,8 @@ } ], "dependencies": { - "escalade": "^3.1.1", - "picocolors": "^1.0.0" + "escalade": "^3.1.2", + "picocolors": "^1.0.1" }, "bin": { "update-browserslist-db": "cli.js" From 5eb09a8bbd2e7bb112ad3a2cce0bec4de15ddd3a Mon Sep 17 00:00:00 2001 From: Ian Krieger Date: Fri, 14 Jun 2024 15:28:41 -0400 Subject: [PATCH 2/4] fix: don't run build-pulish on PR --- .github/workflows/gh-pages.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 212bd186..f2f3ac67 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -4,7 +4,6 @@ on: push: branches: - main - pull_request: jobs: build-publish: From d5ccf70e1ba30655215362eaaf3fafb701be5be5 Mon Sep 17 00:00:00 2001 From: Ian Krieger Date: Mon, 17 Jun 2024 11:57:04 -0400 Subject: [PATCH 3/4] fix: disable analytics --- docusaurus.config.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docusaurus.config.ts b/docusaurus.config.ts index aa511629..f8cddb3a 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -110,6 +110,10 @@ const config: Config = { 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, From 4f7335d7587f1bfc85fa7f97f511a2f59b6dfbba Mon Sep 17 00:00:00 2001 From: Ian Krieger Date: Tue, 25 Jun 2024 13:11:16 -0400 Subject: [PATCH 4/4] feat: Add meta tag with CSP --- docusaurus.config.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docusaurus.config.ts b/docusaurus.config.ts index f8cddb3a..f4a2fc20 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -27,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: [ [