Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 709c31d

Browse files
authoredApr 20, 2021
Add search with DocSearch (#298)
1 parent 2aefce3 commit 709c31d

File tree

5 files changed

+98
-9
lines changed

5 files changed

+98
-9
lines changed
 

‎.github/workflows/docsearch.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: DocSearch Scraper
2+
3+
on:
4+
schedule:
5+
# Run daily at 00:00 UTC
6+
- cron: "0 0 * * *"
7+
8+
jobs:
9+
scrape:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Get DocSearch Config
14+
id: docsearch-config
15+
run: echo "::set-output name=json::$(cat docsearch.json | jq -r tostring)"
16+
- name: Run DocSearch Scraper
17+
run: docker run -e TZ -e API_KEY -e APPLICATION_ID -e CONFIG algolia/docsearch-scraper:latest
18+
env:
19+
TZ: UTC
20+
API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
21+
APPLICATION_ID: "2O5VWTLFC8"
22+
CONFIG: ${{ steps.docsearch-config.outputs.json }}

‎docsearch.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"index_name": "codewars-docs",
3+
"start_urls": ["https://docs.codewars.com/"],
4+
"sitemap_urls": ["https://docs.codewars.com/sitemap.xml"],
5+
"sitemap_alternate_links": true,
6+
"stop_urls": [],
7+
"selectors": {
8+
"lvl0": {
9+
"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()]",
10+
"type": "xpath",
11+
"global": true,
12+
"default_value": "Documentation"
13+
},
14+
"lvl1": "header h1",
15+
"lvl2": "article h2",
16+
"lvl3": "article h3",
17+
"lvl4": "article h4",
18+
"lvl5": "article h5",
19+
"lvl6": "article h6",
20+
"text": "article p, article li"
21+
},
22+
"strip_chars": " .,;:#",
23+
"custom_settings": {
24+
"separatorsToIndex": "_",
25+
"attributesForFaceting": ["language", "version", "type", "docusaurus_tag"],
26+
"attributesToRetrieve": [
27+
"hierarchy",
28+
"content",
29+
"anchor",
30+
"url",
31+
"url_without_anchor",
32+
"type"
33+
]
34+
},
35+
"nb_hits": 3038
36+
}

‎docusaurus.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ module.exports = {
1414
colorMode: {
1515
defaultMode: "dark",
1616
},
17+
algolia: {
18+
// Search only API key
19+
apiKey: "651420d53bdf2d24b6719c6777dc69a4",
20+
indexName: "codewars-docs",
21+
appId: "2O5VWTLFC8",
22+
},
1723
navbar: {
1824
title: "Codewars",
1925
hideOnScroll: true,

‎src/css/custom.css

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@tailwind utilities;
1010

1111
:root {
12-
--ifm-color-primary: #b1361e;
12+
--ifm-color-primary: theme("colors.brand");
1313
--ifm-color-primary-dark: #9f311b;
1414
--ifm-color-primary-darker: #962e19;
1515
--ifm-color-primary-darkest: #7c2615;
@@ -156,3 +156,28 @@ html[data-theme="dark"] .anchored:target {
156156
@apply text-caution-content;
157157
}
158158
}
159+
160+
html[data-theme="light"] .DocSearch {
161+
--docsearch-primary-color: theme("colors.red.500");
162+
--docsearch-highlight-color: var(--docsearch-primary-color);
163+
--docsearch-searchbox-shadow: inset 0 0 0 2px var(--docsearch-primary-color);
164+
--docsearch-logo-color: theme("colors.red.400");
165+
}
166+
167+
html[data-theme="dark"] .DocSearch {
168+
--docsearch-primary-color: theme("colors.red.800");
169+
--docsearch-text-color: var(--ifm-font-color-base);
170+
--docsearch-highlight-color: var(--docsearch-primary-color);
171+
--docsearch-muted-color: var(--ifm-color-secondary-darkest);
172+
--docsearch-container-background: rgba(47, 55, 69, 0.7);
173+
--docsearch-logo-color: theme("colors.red.900");
174+
--docsearch-modal-background: var(--ifm-background-color);
175+
--docsearch-modal-shadow: inset 1px 1px 0 0 #2c2e40, 0 3px 8px 0 #000309;
176+
--docsearch-searchbox-shadow: inset 0 0 0 2px var(--docsearch-primary-color);
177+
--docsearch-footer-background: var(--ifm-background-surface-color);
178+
--docsearch-key-gradient: linear-gradient(
179+
-26.5deg,
180+
var(--ifm-color-emphasis-200) 0%,
181+
var(--ifm-color-emphasis-100) 100%
182+
);
183+
}

‎yarn.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,19 +1120,19 @@
11201120
resolved "https://registry.yarnpkg.com/@csstools/convert-colors/-/convert-colors-1.4.0.tgz#ad495dc41b12e75d588c6db8b9834f08fa131eb7"
11211121
integrity sha512-5a6wqoJV/xEdbRNKVo6I4hO3VjyDq//8q2f9I6PBAvMesJHFauXDorcNCsr9RzvsZnaWi5NYCcfyqP1QeFHFbw==
11221122

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

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

11381138
"@docusaurus/core@2.0.0-alpha.73":

0 commit comments

Comments
 (0)
Please sign in to comment.