diff --git a/blog/230218-weekly-update.md b/blog/230218-weekly-update.md index 12e3ea63e7..9be6e242ed 100644 --- a/blog/230218-weekly-update.md +++ b/blog/230218-weekly-update.md @@ -34,13 +34,13 @@ We'd love to hear your opinions, so please let us know how you're finding them i ## In case you missed it... -### [Sync for Expenses](https://codat2.stoplight.io/docs/sync-for-expenses-v2/fjx7t6em0l1ux-overview) +### [Sync for Expenses](/expenses/overview) Launch new accounting integrations faster and save on ongoing maintenance by standardizing how you sync with bookkeeping software and ERPs. Sync for Expenses is an API and a set of supporting tools. It has been built to enable corporate card and expense management platforms to provide high-quality integrations with multiple accounting software through a standardized API. -[Read the docs...](https://codat2.stoplight.io/docs/sync-for-expenses-v2/fjx7t6em0l1ux-overview) +[Read the docs...](/expenses/overview) ## Deprecations diff --git a/deployment/build.azure-pipelines.yaml b/deployment/build.azure-pipelines.yaml index 62dcdc9950..932b7df2fc 100644 --- a/deployment/build.azure-pipelines.yaml +++ b/deployment/build.azure-pipelines.yaml @@ -77,3 +77,48 @@ stages: RegistryName: ${{ env.registryName }} ImagesToPublish: ${{ parameters.ImagesToPublish }} ArgoApplicationName: docs + + # Docs search is an Algolia DocSearch index filled by Algolia's hosted + # crawler. Ask it to re-crawl once production is live so search picks up + # what just shipped; the crawler's own weekly schedule is the fallback. + - ${{ if and(not(in(variables['Build.Reason'], 'PullRequest')), eq(variables['Build.SourceBranch'], 'refs/heads/main')) }}: + - stage: reindex_search + displayName: Reindex docs search + dependsOn: production + # The vault blocks public network access, so this has to run on a pool + # agent that can reach it (same vault and pool as the build stage). + pool: + name: 'codat-intg-managed-devops-pool-linux' + jobs: + - job: trigger_algolia_crawl + displayName: Trigger Algolia crawl + # The deploy has already succeeded by this point. A failed trigger + # should show as a warning, not turn the release red. + continueOnError: true + steps: + - checkout: none + + - task: AzureKeyVault@2 + displayName: Load Algolia crawler credentials + inputs: + azureSubscription: 'Azure Resource Manager (Integration/UAT)' + KeyVaultName: codat-integration + SecretsFilter: 'docs-algolia-crawler-id,docs-algolia-crawler-user-id,docs-algolia-crawler-api-key' + + - bash: | + set -euo pipefail + status=$(curl --silent --show-error \ + --output response.json --write-out '%{http_code}' \ + --request POST \ + --user "$CRAWLER_USER_ID:$CRAWLER_API_KEY" \ + "https://crawler.algolia.com/api/1/crawlers/$CRAWLER_ID/reindex") + cat response.json; echo + if [ "$status" != "200" ]; then + echo "##vso[task.logissue type=warning]Algolia reindex request failed with HTTP $status" + exit 1 + fi + displayName: Start crawl + env: + CRAWLER_ID: $(docs-algolia-crawler-id) + CRAWLER_USER_ID: $(docs-algolia-crawler-user-id) + CRAWLER_API_KEY: $(docs-algolia-crawler-api-key) diff --git a/docusaurus.config.js b/docusaurus.config.js index ed4349c4b7..1591def4a6 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -267,7 +267,8 @@ const config = { ], ], - themes: ["@docusaurus/theme-mermaid", "docusaurus-theme-search-typesense"], + // The glossary preset does not add the search theme for us, unlike preset-classic. + themes: ["@docusaurus/theme-mermaid", "@docusaurus/theme-search-algolia"], themeConfig: /** @type {import('@docusaurus/preset-classic').ThemeConfig} */ @@ -363,20 +364,13 @@ const config = { copyright: `Copyright © ${new Date().getFullYear()} My Project, Inc. Built with Docusaurus.`, - typesense: { - typesenseCollectionName: "codat-docs", // Replace with your own doc site's name. Should match the collection name in the scraper settings. - typesenseServerConfig: { - nodes: [ - { - host: "d2j9or13nwxb7euap.a1.typesense.net", - port: 443, - protocol: "https", - }, - ], - apiKey: "0Us237UXgfchdk5h7QxMSYzuECnCelO4", - }, - typesenseSearchParameters: {}, // Optional: Typesense search parameters: https://typesense.org/docs/0.24.0/api/search.html#search-parameters - contextualSearch: true, // Optional + // Algolia DocSearch. The app ID and search-only API key are public values, safe to commit. + // The index is populated by the Algolia-hosted crawler, there is no indexing pipeline in this repo. + algolia: { + appId: "G2YF720HDJ", + apiKey: "d73fdb2d3d9dcf6a50e48347f8e31982", // read-only key, never the admin key + indexName: "Codat Docs", + contextualSearch: true, }, sidebar: { diff --git a/package-lock.json b/package-lock.json index 0966668304..1f4bf46b3b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "@docusaurus/preset-classic": "3.9.2", "@docusaurus/theme-live-codeblock": "3.9.2", "@docusaurus/theme-mermaid": "3.9.2", + "@docusaurus/theme-search-algolia": "3.9.2", "@mdx-js/react": "3.1.1", "@stoplight/elements": "8.5.2", "buffer": "6.0.3", @@ -24,7 +25,6 @@ "docusaurus-plugin-image-zoom": "2.0.0", "docusaurus-plugin-module-alias": "0.0.2", "docusaurus-plugin-sass": "0.2.6", - "docusaurus-theme-search-typesense": "0.26.0", "dotenv": "16.6.1", "lottie-react": "2.4.1", "marked": "13.0.3", @@ -156,25 +156,6 @@ "search-insights": ">= 1 < 3" } }, - "node_modules/@algolia/autocomplete-preset-algolia": { - "version": "1.8.2", - "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/@algolia/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.8.2.tgz", - "integrity": "sha1-cG6H+UxfGYwOkFArl68Jre7dzHk=", - "license": "MIT", - "dependencies": { - "@algolia/autocomplete-shared": "1.8.2" - }, - "peerDependencies": { - "@algolia/client-search": ">= 4.9.1 < 6", - "algoliasearch": ">= 4.9.1 < 6" - } - }, - "node_modules/@algolia/autocomplete-preset-algolia/node_modules/@algolia/autocomplete-shared": { - "version": "1.8.2", - "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/@algolia/autocomplete-shared/-/autocomplete-shared-1.8.2.tgz", - "integrity": "sha1-5pct9caTWiQfFuSQmqgpAjOOAp0=", - "license": "MIT" - }, "node_modules/@algolia/autocomplete-shared": { "version": "1.19.2", "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/@algolia/autocomplete-shared/-/autocomplete-shared-1.19.2.tgz", @@ -9568,12 +9549,6 @@ "astring": "bin/astring" } }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "license": "MIT" - }, "node_modules/autoprefixer": { "version": "10.4.23", "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/autoprefixer/-/autoprefixer-10.4.23.tgz", @@ -9625,17 +9600,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/axios": { - "version": "1.13.2", - "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/axios/-/axios-1.13.2.tgz", - "integrity": "sha1-mtoSC3taskUJVT7D5AEjUhEX9oc=", - "license": "MIT", - "dependencies": { - "follow-redirects": "^1.15.6", - "form-data": "^4.0.4", - "proxy-from-env": "^1.1.0" - } - }, "node_modules/babel-loader": { "version": "9.2.1", "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/babel-loader/-/babel-loader-9.2.1.tgz", @@ -10679,18 +10643,6 @@ "node": ">=10" } }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha1-w9RaizT9cwYxoRCoolIGgrMdWn8=", - "license": "MIT", - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/comma-separated-tokens": { "version": "2.0.3", "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz", @@ -12446,15 +12398,6 @@ "robust-predicates": "^3.0.0" } }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "license": "MIT", - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/depd/-/depd-2.0.0.tgz", @@ -12635,39 +12578,6 @@ "sass": "^1.30.0" } }, - "node_modules/docusaurus-theme-search-typesense": { - "version": "0.26.0", - "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/docusaurus-theme-search-typesense/-/docusaurus-theme-search-typesense-0.26.0.tgz", - "integrity": "sha1-fwAJ9WONd84yeEwslG48VU8voCw=", - "license": "MIT", - "dependencies": { - "@docusaurus/core": "~3.9.0", - "@docusaurus/logger": "~3.9.0", - "@docusaurus/plugin-content-docs": "~3.9.0", - "@docusaurus/theme-common": "~3.9.0", - "@docusaurus/theme-translations": "~3.9.0", - "@docusaurus/utils": "~3.9.0", - "@docusaurus/utils-validation": "~3.9.0", - "algoliasearch-helper": "^3.13.3", - "clsx": "^2.0.0", - "eta": "^2.2.0", - "fs-extra": "^11.1.1", - "lodash": "^4.17.21", - "tslib": "^2.6.0", - "typesense-docsearch-react": "^3.4.1", - "typesense-instantsearch-adapter": "^2.9.0-5", - "utility-types": "^3.10.0" - }, - "engines": { - "node": ">=18" - }, - "peerDependencies": { - "@docusaurus/core": "~3.8.0", - "@docusaurus/theme-common": "~3.8.0", - "react": "^18.0.0 || ^19.0.0", - "react-dom": "^18.0.0 || ^19.0.0" - } - }, "node_modules/dom-converter": { "version": "0.2.0", "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/dom-converter/-/dom-converter-0.2.0.tgz", @@ -12979,21 +12889,6 @@ "node": ">= 0.4" } }, - "node_modules/es-set-tostringtag": { - "version": "2.1.0", - "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", - "integrity": "sha1-8x274MGDsAptJutjJcgQwP0YvU0=", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.6", - "has-tostringtag": "^1.0.2", - "hasown": "^2.0.2" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/esast-util-from-estree": { "version": "2.0.0", "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/esast-util-from-estree/-/esast-util-from-estree-2.0.0.tgz", @@ -13817,22 +13712,6 @@ "integrity": "sha1-h7zIoaDnQAD/K/mAIRBwjPsC624=", "license": "MIT" }, - "node_modules/form-data": { - "version": "4.0.5", - "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/form-data/-/form-data-4.0.5.tgz", - "integrity": "sha1-tJ5IhYBF/0y/awPhgFzrytNnkFM=", - "license": "MIT", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "es-set-tostringtag": "^2.1.0", - "hasown": "^2.0.2", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/form-data-encoder": { "version": "2.1.4", "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/form-data-encoder/-/form-data-encoder-2.1.4.tgz", @@ -16711,19 +16590,6 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "node_modules/loglevel": { - "version": "1.9.2", - "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/loglevel/-/loglevel-1.9.2.tgz", - "integrity": "sha1-wuAo1sdXcgEH305kUIUw22Yhugg=", - "license": "MIT", - "engines": { - "node": ">= 0.6.0" - }, - "funding": { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/loglevel" - } - }, "node_modules/longest-streak": { "version": "3.1.0", "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/longest-streak/-/longest-streak-3.1.0.tgz", @@ -22114,12 +21980,6 @@ "node": ">= 0.10" } }, - "node_modules/proxy-from-env": { - "version": "1.1.0", - "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha1-4QLxbKNVQkhldV0sno6k8k1Yw+I=", - "license": "MIT" - }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/punycode/-/punycode-2.3.1.tgz", @@ -25379,105 +25239,6 @@ "is-typedarray": "^1.0.0" } }, - "node_modules/typesense": { - "version": "1.8.2", - "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/typesense/-/typesense-1.8.2.tgz", - "integrity": "sha1-FjQf3U7asCsz+swU4dJ6bVjb4OU=", - "license": "Apache-2.0", - "dependencies": { - "axios": "^1.6.0", - "loglevel": "^1.8.1" - }, - "engines": { - "node": ">=18" - }, - "peerDependencies": { - "@babel/runtime": "^7.23.2" - } - }, - "node_modules/typesense-docsearch-css": { - "version": "0.4.1", - "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/typesense-docsearch-css/-/typesense-docsearch-css-0.4.1.tgz", - "integrity": "sha1-RX1K0tYwIcfMbhIIHDeMA2eokcA=", - "license": "MIT" - }, - "node_modules/typesense-docsearch-react": { - "version": "3.4.1", - "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/typesense-docsearch-react/-/typesense-docsearch-react-3.4.1.tgz", - "integrity": "sha1-dU1SRyu5sZqR0hP1ddfMBqWKCHg=", - "license": "MIT", - "dependencies": { - "@algolia/autocomplete-core": "1.8.2", - "@algolia/autocomplete-preset-algolia": "1.8.2", - "typesense": "^1.7.2", - "typesense-docsearch-css": "^0.4.1", - "typesense-instantsearch-adapter": "^2.7.1" - }, - "peerDependencies": { - "@types/react": ">= 16.8.0 < 19.0.0", - "react": ">= 16.8.0 < 19.0.0", - "react-dom": ">= 16.8.0 < 19.0.0" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - }, - "react": { - "optional": true - }, - "react-dom": { - "optional": true - } - } - }, - "node_modules/typesense-docsearch-react/node_modules/@algolia/autocomplete-core": { - "version": "1.8.2", - "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/@algolia/autocomplete-core/-/autocomplete-core-1.8.2.tgz", - "integrity": "sha1-jXWMhlJ0LidhRQ0rYVqEH8ok4Q4=", - "license": "MIT", - "dependencies": { - "@algolia/autocomplete-shared": "1.8.2" - } - }, - "node_modules/typesense-docsearch-react/node_modules/@algolia/autocomplete-shared": { - "version": "1.8.2", - "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/@algolia/autocomplete-shared/-/autocomplete-shared-1.8.2.tgz", - "integrity": "sha1-5pct9caTWiQfFuSQmqgpAjOOAp0=", - "license": "MIT" - }, - "node_modules/typesense-instantsearch-adapter": { - "version": "2.9.0", - "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/typesense-instantsearch-adapter/-/typesense-instantsearch-adapter-2.9.0.tgz", - "integrity": "sha1-zmtx8AS0friPES23QTjXxpMrCIo=", - "hasInstallScript": true, - "license": "Apache-2.0", - "dependencies": { - "typesense": "^2.1.0-1" - }, - "engines": { - "node": ">=18" - }, - "peerDependencies": { - "@babel/runtime": "^7.24.1" - } - }, - "node_modules/typesense-instantsearch-adapter/node_modules/typesense": { - "version": "2.1.0", - "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/typesense/-/typesense-2.1.0.tgz", - "integrity": "sha1-EXKtu8tCyziIBDxmRlr+iCw1WH4=", - "license": "Apache-2.0", - "dependencies": { - "axios": "^1.8.4", - "loglevel": "^1.8.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18" - }, - "peerDependencies": { - "@babel/runtime": "^7.23.2" - } - }, "node_modules/ufo": { "version": "1.6.1", "resolved": "https://pkgs.dev.azure.com/codat/Codat/_packaging/codat-npm/npm/registry/ufo/-/ufo-1.6.1.tgz", diff --git a/package.json b/package.json index 22222ea007..104fc025ac 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "@docusaurus/preset-classic": "3.9.2", "@docusaurus/theme-live-codeblock": "3.9.2", "@docusaurus/theme-mermaid": "3.9.2", + "@docusaurus/theme-search-algolia": "3.9.2", "@mdx-js/react": "3.1.1", "@stoplight/elements": "8.5.2", "buffer": "6.0.3", @@ -39,7 +40,6 @@ "docusaurus-plugin-image-zoom": "2.0.0", "docusaurus-plugin-module-alias": "0.0.2", "docusaurus-plugin-sass": "0.2.6", - "docusaurus-theme-search-typesense": "0.26.0", "dotenv": "16.6.1", "lottie-react": "2.4.1", "marked": "13.0.3", diff --git a/src/styles/components/_search.scss b/src/styles/components/_search.scss index 64caea12f9..be00602f73 100644 --- a/src/styles/components/_search.scss +++ b/src/styles/components/_search.scss @@ -33,6 +33,12 @@ html[data-theme="dark"] { } } +// The modal renders outside #__docusaurus. Our global input:focus-visible ring +// outranks DocSearch's own outline reset and collides with "Clear the query". +.DocSearch-Input:focus-visible { + outline: none; +} + //overrides #__docusaurus { [class*="navbarSearch"] { @@ -59,6 +65,9 @@ html[data-theme="dark"] { } .DocSearch-Button { + // DocSearch v4 resets the button to content-box, so without this the padding + // and border push it past its container and over the navbar CTA. + box-sizing: border-box; width: 100%; box-shadow: var(--docsearch-searchbox-shadow); border: 2px solid rgba(24, 16, 58, 0.3); @@ -71,10 +80,15 @@ html[data-theme="dark"] { display: flex; align-items: center; justify-content: center; + gap: 0.125rem; - padding: 0.125rem; + // One compact pill for the whole shortcut, with room above and below + // inside the 32px button. + box-sizing: border-box; + height: 1.25rem; + padding: 0 0.25rem; border: 1px solid var(--search-keys-border-c); - border-radius: 6px; + border-radius: 4px; .DocSearch-Button-Key { position: static; @@ -84,8 +98,18 @@ html[data-theme="dark"] { width: auto; height: auto; + font-size: 0.75rem; color: var(--search-muted-c); + // DocSearch v4 styles each key as its own chip, which doubles up + // with the pill around them. + background: none; + border: 0; border-radius: 0; + + svg { + width: auto; + height: 0.875rem; + } } } diff --git a/src/utils/clientModules.js b/src/utils/clientModules.js index 5a69cf5bd5..c21954cd15 100644 --- a/src/utils/clientModules.js +++ b/src/utils/clientModules.js @@ -1,6 +1,6 @@ import { trackEvent, trackSearch, trackCodeExample } from "./amplitude"; -// Track search interactions with Typesense +// Track search interactions with Algolia DocSearch function setupSearchTracking() { // Wait for the search box to be available const searchObserver = new MutationObserver(() => { @@ -24,7 +24,7 @@ function setupSearchTracking() { if (query.length >= 3) { // Count visible results if possible const resultsContainer = document.querySelector( - ".DocSearch-Dropdown, .typesense-search-results", + ".DocSearch-Dropdown", ); let resultsCount = null; @@ -36,7 +36,7 @@ function setupSearchTracking() { } trackSearch(query, resultsCount, { - search_method: "typesense", + search_method: "algolia", search_context: "documentation", }); } @@ -57,7 +57,7 @@ function setupSearchTracking() { trackEvent("Search Result Clicked", { result_title: title, result_url: url, - search_method: "typesense", + search_method: "algolia", }); } });