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

feat: new search index and auto scraping in CI #1082

Merged
merged 16 commits into from
Jan 27, 2023
Merged
20 changes: 19 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ jobs:
path: build
- name: Deploy to Netlify
# Fork of https://github.com/nwtgck/actions-netlify for security reasons
uses: tauri-apps/actions-netlify@v1.2.4
uses: tauri-apps/actions-netlify@v2.0.0
with:
publish-dir: './build'
netlify-config-path: ./netlify.toml
Expand All @@ -139,3 +139,21 @@ jobs:
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

update-search-index:
needs: deploy-to-netlify
if: github.event_name == 'push' && github.ref_name == 'dev'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run scraper
env:
HOST_URL: ${{ secrets.MEILISEARCH_HOST_URL }}
API_KEY: ${{ secrets.MEILISEARCH_API_KEY }}
CONFIG_FILE_PATH: ${{ github.workspace }}/scraper.json
run: |
docker run -t --rm \
-e MEILISEARCH_HOST_URL=$HOST_URL \
-e MEILISEARCH_API_KEY=$API_KEY \
-v $CONFIG_FILE_PATH:/docs-scraper/scraper.json \
getmeili/docs-scraper:v0.12.6 pipenv run ./docs_scraper ./scraper.json
66 changes: 66 additions & 0 deletions scraper.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"index_uid": "docs-v1",
"start_urls": [
{
"url": "https://tauri.app/v1/guides/",
"selectors_key": "guides"
},
{
"url": "https://tauri.app/v1/api/js/",
"selectors_key": "api-js"
},
{
"url": "https://tauri.app/v1/references/",
"selectors_key": "references"
},
"https://tauri.app/v1/"
],
"sitemap_urls": ["https://tauri.app/sitemap.xml"],
"stop_urls": [],
"selectors": {
"default": {
"lvl0": "article h1",
"lvl1": "article h2",
"lvl2": "article h3",
"lvl3": "article h4",
"lvl4": "article h5",
"text": "article p, article li"
},
"guides": {
"lvl0": {
"selector": "",
"default_value": "Documentation"
},
"lvl1": "article h1",
"lvl2": "article h2",
"lvl3": "article h3",
"lvl4": "article h4",
"lvl5": "article h5",
"text": "article p, article li"
},
"api-js": {
"lvl0": {
"selector": "",
"default_value": "JS API"
},
"lvl1": "article h1",
"lvl2": "article h2",
"lvl3": "article h3",
"lvl4": "article h4",
"lvl5": "article h5",
"text": "article p, article li"
},
"references": {
"lvl0": {
"selector": "",
"default_value": "References"
},
"lvl1": "article h1",
"lvl2": "article h2",
"lvl3": "article h3",
"lvl4": "article h4",
"lvl5": "article h5",
"text": "article p, article li"
}
}
}
6 changes: 3 additions & 3 deletions src/theme/SearchBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export default function Component() {
const DocsSearchBar = require('docs-searchbar.js').default

DocsSearchBar({
hostUrl: 'https://search2.tauri.studio',
hostUrl: 'https://ms-4ebb96f179f0-1619.fra.meilisearch.io',
apiKey:
'XZEH8BS90ee09c45215a8421c06857bcbde5c1a6797bdf4859a57a3ac1228a2b81df0994',
indexUid: 'consolidated',
'3eb6db150af1abefe000f00386e149dfb5a006932cab55d1ccd810b8672a4e12',
indexUid: 'docs-v1',
inputSelector: '#search-bar-input',
debug: process.env.NODE_ENV === 'development',
})
Expand Down
71 changes: 54 additions & 17 deletions src/theme/SearchBar/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,52 @@
border-radius: 0.5rem;
}

.meilisearch-autocomplete .dsb-suggestion:hover {
.meilisearch-autocomplete .docs-searchbar-suggestion {
display: block;
position: relative;
padding: 0 8px;
overflow: hidden;
}

.meilisearch-autocomplete .dsb-suggestion:hover,
.meilisearch-autocomplete .dsb-suggestion.dsb-cursor {
background-color: var(--ifm-dropdown-hover-background-color);
color: var(--ifm-dropdown-link-color);
}

.meilisearch-autocomplete .docs-searchbar-suggestion--content {
display: block;
width: 70%;
position: relative;
padding: 5.3333333333px 0 5.3333333333px 10.6666666667px;
cursor: pointer;
}
.meilisearch-autocomplete .docs-searchbar-suggestion--content:before {
content: '';
position: absolute;
display: block;
top: 0;
height: 100%;
width: 1px;
background: #ddd;
left: -1px;
}

.meilisearch-autocomplete .docs-searchbar-suggestion--wrapper {
width: 100%;
display: flex;
align-items: flex-start;
padding: 8px 0 0;
}

/* Main category */
.meilisearch-autocomplete .docs-searchbar-suggestion--category-header {
display: none;
font-size: var(--ifm-h2-font-size);
font-size: var(--ifm-h3-font-size);
color: var(--ifm-heading-color);
font-family: var(--ifm-heading-font-family);
font-weight: var(--ifm-heading-font-weight);
border-bottom: 1px solid #ddd;
}

/* Only show the first category */
Expand All @@ -51,18 +85,8 @@
display: block;
}

/* Category Column */
.meilisearch-autocomplete .docs-searchbar-suggestion--subcategory-column {
display: none;
}

/* Category Inline */
.meilisearch-autocomplete .docs-searchbar-suggestion--subcategory-inline {
font-size: var(--ifm-h4-font-size);
color: var(--ifm-font-color-base);
font-family: var(--ifm-heading-font-family);
font-weight: var(--ifm-heading-font-weight);
margin-top: 0.5em;
display: none;
}

/* Title */
Expand All @@ -72,16 +96,29 @@
color: var(--ifm-font-color-base);
font-family: var(--ifm-heading-font-family);
font-weight: var(--ifm-heading-font-weight);
margin-top: 0.5em;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.meilisearch-autocomplete .docs-searchbar-suggestion--subcategory-column {
width: 30%;
text-align: right;
position: relative;
padding: 5.3333333333px 10.6666666667px;
FabianLars marked this conversation as resolved.
Show resolved Hide resolved
color: #a4a7ae;
font-size: 0.9em;
word-wrap: break-word;
}

/* Description */
.meilisearch-autocomplete .docs-searchbar-suggestion--text {
font-style: italic;
font-size: 0.85em;
color: var(--ifm-font-color-base);
/* Limit displayed lines of content preview to 3 */
-webkit-line-clamp: 3;
display: -webkit-box;
text-overflow: ellipsis;
overflow: hidden;
-webkit-box-orient: vertical;
}

/* Highlighted text */
Expand Down