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 search with DocSearch #298

Merged
merged 2 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/docsearch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: DocSearch Scraper

on:
schedule:
# Run daily at 00:00 UTC
- cron: "0 0 * * *"

jobs:
scrape:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get DocSearch Config
id: docsearch-config
run: echo "::set-output name=json::$(cat docsearch.json | jq -r tostring)"
- name: Run DocSearch Scraper
run: docker run -e TZ -e API_KEY -e APPLICATION_ID -e CONFIG algolia/docsearch-scraper:latest
env:
TZ: UTC
API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
APPLICATION_ID: "2O5VWTLFC8"
CONFIG: ${{ steps.docsearch-config.outputs.json }}
36 changes: 36 additions & 0 deletions docsearch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"index_name": "codewars-docs",
"start_urls": ["https://docs.codewars.com/"],
"sitemap_urls": ["https://docs.codewars.com/sitemap.xml"],
"sitemap_alternate_links": true,
"stop_urls": [],
"selectors": {
"lvl0": {
"selector": "(//ul[contains(@class,'menu__list')]//a[contains(@class, 'menu__link menu__link--sublist menu__link--active')]/text() | //nav[contains(@class, 'navbar')]//a[contains(@class, 'navbar__link--active')]/text())[last()]",
"type": "xpath",
"global": true,
"default_value": "Documentation"
},
"lvl1": "header h1",
"lvl2": "article h2",
"lvl3": "article h3",
"lvl4": "article h4",
"lvl5": "article h5",
"lvl6": "article h6",
"text": "article p, article li"
},
"strip_chars": " .,;:#",
"custom_settings": {
"separatorsToIndex": "_",
"attributesForFaceting": ["language", "version", "type", "docusaurus_tag"],
"attributesToRetrieve": [
"hierarchy",
"content",
"anchor",
"url",
"url_without_anchor",
"type"
]
},
"nb_hits": 3038
}
6 changes: 6 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ module.exports = {
colorMode: {
defaultMode: "dark",
},
algolia: {
// Search only API key
apiKey: "651420d53bdf2d24b6719c6777dc69a4",
indexName: "codewars-docs",
appId: "2O5VWTLFC8",
},
navbar: {
title: "Codewars",
hideOnScroll: true,
Expand Down
27 changes: 26 additions & 1 deletion src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@tailwind utilities;

:root {
--ifm-color-primary: #b1361e;
--ifm-color-primary: theme("colors.brand");
--ifm-color-primary-dark: #9f311b;
--ifm-color-primary-darker: #962e19;
--ifm-color-primary-darkest: #7c2615;
Expand Down Expand Up @@ -156,3 +156,28 @@ html[data-theme="dark"] .anchored:target {
@apply text-caution-content;
}
}

html[data-theme="light"] .DocSearch {
--docsearch-primary-color: theme("colors.red.500");
--docsearch-highlight-color: var(--docsearch-primary-color);
--docsearch-searchbox-shadow: inset 0 0 0 2px var(--docsearch-primary-color);
--docsearch-logo-color: theme("colors.red.400");
}

html[data-theme="dark"] .DocSearch {
--docsearch-primary-color: theme("colors.red.800");
--docsearch-text-color: var(--ifm-font-color-base);
--docsearch-highlight-color: var(--docsearch-primary-color);
--docsearch-muted-color: var(--ifm-color-secondary-darkest);
--docsearch-container-background: rgba(47, 55, 69, 0.7);
--docsearch-logo-color: theme("colors.red.900");
--docsearch-modal-background: var(--ifm-background-color);
--docsearch-modal-shadow: inset 1px 1px 0 0 #2c2e40, 0 3px 8px 0 #000309;
--docsearch-searchbox-shadow: inset 0 0 0 2px var(--docsearch-primary-color);
--docsearch-footer-background: var(--ifm-background-surface-color);
--docsearch-key-gradient: linear-gradient(
-26.5deg,
var(--ifm-color-emphasis-200) 0%,
var(--ifm-color-emphasis-100) 100%
);
}
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1120,19 +1120,19 @@
resolved "https://registry.yarnpkg.com/@csstools/convert-colors/-/convert-colors-1.4.0.tgz#ad495dc41b12e75d588c6db8b9834f08fa131eb7"
integrity sha512-5a6wqoJV/xEdbRNKVo6I4hO3VjyDq//8q2f9I6PBAvMesJHFauXDorcNCsr9RzvsZnaWi5NYCcfyqP1QeFHFbw==

"@docsearch/css@3.0.0-alpha.35":
version "3.0.0-alpha.35"
resolved "https://registry.yarnpkg.com/@docsearch/css/-/css-3.0.0-alpha.35.tgz#17579a6649cae7303ecac400795e84b1a906a5ed"
integrity sha512-Qaft+2qy7VYzy3j02OqurXtm1tCNXAfTO1u8R7ww4qB9+1Ns80kn9tJejbtQclgBbFCGf7kn7JShxwlpEMLUzw==
"@docsearch/css@3.0.0-alpha.36":
version "3.0.0-alpha.36"
resolved "https://registry.yarnpkg.com/@docsearch/css/-/css-3.0.0-alpha.36.tgz#0af69a86b845974d0f8cab62db0218f66b6ad2d6"
integrity sha512-zSN2SXuZPDqQaSFzYa1kOwToukqzhLHG7c66iO+/PlmWb6/RZ5cjTkG6VCJynlohRWea7AqZKWS/ptm8kM2Dmg==

"@docsearch/react@^3.0.0-alpha.33":
version "3.0.0-alpha.35"
resolved "https://registry.yarnpkg.com/@docsearch/react/-/react-3.0.0-alpha.35.tgz#ce7c2480384c4721976dc49f0962701e98b309d2"
integrity sha512-gL3CsZDvRhrrte2zjUFfnKC/jG2o2S6W9+v+m46Ro0juzfdSoKnVLyCr6MUi94asE6yF1zjCX1Z9xcpw0wq8YA==
version "3.0.0-alpha.36"
resolved "https://registry.yarnpkg.com/@docsearch/react/-/react-3.0.0-alpha.36.tgz#f2dbd53ba9c389bc19aea89a3ad21782fa6b4bb5"
integrity sha512-synYZDHalvMzesFiy7kK+uoz4oTdWSTbe2cU+iiUjwFMyQ+WWjWwGVnvcvk+cjj9pRCVaZo5y5WpqNXq1j8k9Q==
dependencies:
"@algolia/autocomplete-core" "1.0.0-alpha.44"
"@algolia/autocomplete-preset-algolia" "1.0.0-alpha.44"
"@docsearch/css" "3.0.0-alpha.35"
"@docsearch/css" "3.0.0-alpha.36"
algoliasearch "^4.0.0"

"@docusaurus/core@2.0.0-alpha.73":
Expand Down