diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 68e1ce3084..85eaac1dfa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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 diff --git a/scraper.json b/scraper.json new file mode 100644 index 0000000000..3d7ab26cb9 --- /dev/null +++ b/scraper.json @@ -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 :not(blockquote) > 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" + } + } +} diff --git a/src/theme/SearchBar/index.js b/src/theme/SearchBar/index.js index e0bd15e4c4..952f22b423 100644 --- a/src/theme/SearchBar/index.js +++ b/src/theme/SearchBar/index.js @@ -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', }) diff --git a/src/theme/SearchBar/style.css b/src/theme/SearchBar/style.css index ca5b678952..eb421d5bd3 100644 --- a/src/theme/SearchBar/style.css +++ b/src/theme/SearchBar/style.css @@ -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 */ @@ -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 */ @@ -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; + 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 */