Skip to content

Commit 8f464e2

Browse files
authored
Revert "Troubleshooting search (#2420)" (#2426)
This reverts commit dced671.
1 parent e48ad30 commit 8f464e2

File tree

5 files changed

+205
-22
lines changed

5 files changed

+205
-22
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Algolia scrape
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
parameter:
7+
description: Run from dispatch
8+
branches:
9+
- main
10+
push:
11+
branches:
12+
- main
13+
14+
jobs:
15+
scrape:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Wait for 8 minutes
19+
run: sleep 480s
20+
shell: bash
21+
- name: check out code 🛎
22+
uses: actions/checkout@v2
23+
# when scraping the site, inject secrets as environment variables
24+
# then pass their values into the Docker container using "-e" syntax
25+
# and inject config.json contents as another variable
26+
27+
# prefer this file (algolia-scrap.yml) over algolia-config.json for ranking
28+
29+
- name: scrape the site and send to Algolia 🧽
30+
env:
31+
APPLICATION_ID: ${{ secrets.ALGOLIA_APPLICATION_ID }}
32+
API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
33+
run: |
34+
docker run \
35+
-e APPLICATION_ID -e API_KEY \
36+
-e CONFIG="$(cat algolia-config.json)" \
37+
algolia/docsearch-scraper:latest
38+
curl -X PUT \
39+
-H "X-Algolia-API-Key: ${API_KEY}" \
40+
-H "X-Algolia-Application-Id: ${APPLICATION_ID}" \
41+
--data-binary '{
42+
"ranking": ["desc(weight.page_rank)", "desc(weight.level)", "asc(weight.position)", "words", "exact", "attribute", "proximity", "typo"]
43+
}' \
44+
"https://${APPLICATION_ID}.algolia.net/1/indexes/docs/settings?forwardToReplicas=true"

algolia-config.json

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
{
2+
"index_name": "docs",
3+
"start_urls": [
4+
{
5+
"url": "https://semgrep.dev/docs/release-notes",
6+
"tags": ["release_notes"],
7+
"page_rank": -100
8+
},
9+
{
10+
"url": "https://semgrep.dev/docs/rule-updates",
11+
"tags": ["rule_updates"],
12+
"page_rank": -100
13+
},
14+
{
15+
"url": "https://semgrep.dev/docs"
16+
}
17+
],
18+
"sitemap_urls": ["https://semgrep.dev/docs/sitemap.xml"],
19+
"stop_urls": [
20+
"https://semgrep.dev/docs/tags/*",
21+
"https://semgrep.dev/docs/category/*"
22+
],
23+
"js_render": false,
24+
"selectors": {
25+
"default": {
26+
"lvl0": {
27+
"selector": ".breadcrumbs > li:nth-child(2) span.breadcrumbs__link",
28+
"global": true,
29+
"default_value": "Semgrep documentation"
30+
},
31+
"lvl1": "article h1",
32+
"lvl2": "article h2",
33+
"lvl3": "article h3",
34+
"lvl4": "article h4",
35+
"lvl5": "article h5, article td:first-child",
36+
"lvl6": "article h6",
37+
"text": "article p, article li, article td:last-child, article code, article div table td, article div table th"
38+
}
39+
},
40+
"strip_chars": " .,;:#()",
41+
"custom_settings": {
42+
"indexLanguages" : [
43+
"en"
44+
],
45+
"queryLanguages" : [
46+
"en"
47+
],
48+
"disableTypoToleranceOnWords" : [
49+
"severity",
50+
"security",
51+
"git",
52+
"coverage",
53+
"leverage",
54+
"teams",
55+
"terms",
56+
"IdP",
57+
"IDE",
58+
"Jira"
59+
],
60+
"separatorsToIndex": "_",
61+
"attributesForFaceting": [
62+
"language",
63+
"version",
64+
"type",
65+
"docusaurus_tag"
66+
],
67+
"attributesToRetrieve": [
68+
"hierarchy",
69+
"content",
70+
"anchor",
71+
"url",
72+
"url_without_anchor",
73+
"type"
74+
],
75+
"synonyms": [
76+
[
77+
"taint mode",
78+
"taint tracking"
79+
],
80+
[
81+
"roles",
82+
"RBAC"
83+
],
84+
[
85+
"single sign-on",
86+
"SSO"
87+
],
88+
[
89+
"single sign on",
90+
"SSO"
91+
],
92+
[
93+
"CI",
94+
"continuous integration"
95+
],
96+
[
97+
"CI/CD",
98+
"continuous integration"
99+
],
100+
[
101+
"pull request comments",
102+
"PR comments"
103+
],
104+
[
105+
"merge request comments",
106+
"MR comments"
107+
],
108+
[
109+
"Semgrep Cloud Platform",
110+
"SCP"
111+
],
112+
[
113+
"Semgrep Supply Chain",
114+
"SSC"
115+
],
116+
[
117+
"Identity provider",
118+
"IdP"
119+
],
120+
[
121+
"Jira integration",
122+
"Jira"
123+
],
124+
[
125+
"lockfileless",
126+
"without lockfiles"
127+
],
128+
[
129+
"node.js",
130+
"JavaScript"
131+
],
132+
[
133+
"nodejs",
134+
"JavaScript"
135+
],
136+
[
137+
"click to fix",
138+
"click-to-fix"
139+
]
140+
]
141+
},
142+
"conversation_id": [
143+
"833762294"
144+
],
145+
"nb_hits": 16653
146+
}

docusaurus.config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ module.exports = {
1414
projectName: 'semgrep', // Usually your repo name.
1515
trailingSlash: false,
1616
themeConfig: {
17-
// Disable Algolia search - we use custom Meilisearch integration
18-
algolia: null,
1917
docs: {
2018
sidebar: {
2119
hideable: true,

src/theme/Navbar/Search/index.tsx

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ const MeilisearchSearchBar: React.FC<MeilisearchSearchBarProps> = ({
659659
onClick={handleBlur}
660660
/>
661661
)}
662-
<div ref={searchContainerRef} style={{ position: 'relative', width: '100%', zIndex: 1000, pointerEvents: 'auto' }}>
662+
<div ref={searchContainerRef} style={{ position: 'relative', width: '100%', zIndex: 1000 }}>
663663
<div
664664
onClick={handleFocus}
665665
style={{
@@ -674,8 +674,7 @@ const MeilisearchSearchBar: React.FC<MeilisearchSearchBarProps> = ({
674674
minWidth: (isFocused || aiResponse || aiLoading) ? '450px' : '250px',
675675
width: (isFocused || aiResponse || aiLoading) ? '100%' : 'auto',
676676
maxWidth: (isFocused || aiResponse || aiLoading) ? '600px' : '300px',
677-
boxShadow: (isFocused || aiResponse || aiLoading) ? '0 8px 25px rgba(0, 212, 170, 0.2)' : '0 2px 8px rgba(0,0,0,0.08)',
678-
pointerEvents: 'auto'
677+
boxShadow: (isFocused || aiResponse || aiLoading) ? '0 8px 25px rgba(0, 212, 170, 0.2)' : '0 2px 8px rgba(0,0,0,0.08)'
679678
}}
680679
>
681680
<input
@@ -695,9 +694,7 @@ const MeilisearchSearchBar: React.FC<MeilisearchSearchBarProps> = ({
695694
background: 'transparent',
696695
color: '#111827',
697696
fontWeight: '500',
698-
transition: 'font-size 0.2s ease',
699-
pointerEvents: 'auto',
700-
cursor: 'text'
697+
transition: 'font-size 0.2s ease'
701698
}}
702699
/>
703700
{isLoading && <span style={{fontSize: '12px', color: '#00D4AA', marginLeft: '8px', fontWeight: '500'}}>Searching...</span>}
@@ -1144,30 +1141,29 @@ const getMeilisearchConfig = (): SearchConfig => {
11441141
};
11451142
}
11461143

1147-
const isProduction = window.location.hostname === 'semgrep.dev';
11481144
const isNetlifyPreview = window.location.hostname.includes('deploy-preview');
11491145
const isTestingBranch = window.location.hostname.includes('meilisearch-testing') || isNetlifyPreview;
11501146
const isDevelopment = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
11511147

1152-
if (isProduction || isNetlifyPreview || isTestingBranch || isDevelopment) {
1148+
if (isNetlifyPreview || isTestingBranch || isDevelopment) {
11531149
const isNetlify = window.location.hostname.includes('netlify.app') || isNetlifyPreview;
11541150

1155-
return {
1156-
enabled: true,
1157-
hostUrl: isNetlify ?
1151+
return {
1152+
enabled: true,
1153+
hostUrl: isNetlify ?
11581154
`${window.location.origin}/.netlify/functions/meilisearch` :
11591155
"https://ms-3ade175771ef-34593.sfo.meilisearch.io",
11601156
apiKey: "",
11611157
indexUid: "semgrep_docs",
1162-
placeholder: "Search docs..."
1163-
};
1158+
placeholder: "Search docs..."
1159+
};
11641160
}
11651161

1166-
return {
1167-
enabled: false,
1168-
hostUrl: "",
1169-
apiKey: "",
1170-
indexUid: "",
1162+
return {
1163+
enabled: false,
1164+
hostUrl: "",
1165+
apiKey: "",
1166+
indexUid: "",
11711167
placeholder: "Search docs..."
11721168
};
11731169
};

src/theme/Root.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ export default function Root({children}: {children: React.ReactNode}): JSX.Eleme
1111
const shouldEnableChatbot = () => {
1212
if (typeof window === 'undefined') return false;
1313

14-
const isProduction = window.location.hostname === 'semgrep.dev';
1514
const isNetlifyPreview = window.location.hostname.includes('deploy-preview');
1615
const isTestingBranch = window.location.hostname.includes('meilisearch-testing') || isNetlifyPreview;
1716
const isDevelopment = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
1817

19-
return isProduction || isNetlifyPreview || isTestingBranch || isDevelopment;
18+
return isNetlifyPreview || isTestingBranch || isDevelopment;
2019
};
2120

2221
return (

0 commit comments

Comments
 (0)