From 959d83a000458e0854c25666600bc23d823487b0 Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Sun, 14 Mar 2021 01:51:28 +0900 Subject: [PATCH] feat(website): enable docsearch (#409) --- .github/workflows/scrape.yml | 24 ++++++++++++++++++++++++ docsearch.json | 35 +++++++++++++++++++++++++++++++++++ website/docusaurus.config.js | 5 +++++ 3 files changed, 64 insertions(+) create mode 100644 .github/workflows/scrape.yml create mode 100644 docsearch.json diff --git a/.github/workflows/scrape.yml b/.github/workflows/scrape.yml new file mode 100644 index 00000000..3d99bb64 --- /dev/null +++ b/.github/workflows/scrape.yml @@ -0,0 +1,24 @@ +name: DocSearch Scraper + +on: + schedule: + - cron: '53 1 * * *' + +jobs: + scrape: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Get DocSearch configuration + id: docsearch-config + run: echo "::set-output name=json::$(cat docsearch.json | jq -r tostring)" + - name: Pull DocSearch Scraper + run: docker pull algolia/docsearch-scraper:latest + - 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: ${{ secrets.ALGOLIA_APPLICATION_ID }} + CONFIG: ${{ steps.docsearch-config.outputs.json }} diff --git a/docsearch.json b/docsearch.json new file mode 100644 index 00000000..2f5a272c --- /dev/null +++ b/docsearch.json @@ -0,0 +1,35 @@ +{ + "custom_settings": { + "separatorsToIndex": "_", + "attributesForFaceting": ["language", "version", "type", "docusaurus_tag"], + "attributesToRetrieve": [ + "hierarchy", + "content", + "anchor", + "url", + "url_without_anchor", + "type" + ] + }, + "index_name": "docusaurus", + "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, article td:first-child", + "lvl6": "article h6", + "text": "article p, article li, article td:last-child" + }, + "sitemap_alternate_links": true, + "sitemap_urls": ["https://manael.org/sitemap.xml"], + "start_urls": ["https://manael.org/"], + "strip_chars": " .,;:#", + "stop_urls": [] +} diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index a9376ffd..f817945b 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -35,6 +35,11 @@ module.exports = { projectName: 'manael', tagline: 'Manael is a simple HTTP proxy for processing images.', themeConfig: { + algolia: { + appId: 'ZX7VYOHRJ3', + apiKey: '43f66f766ffb77ee2280608d793ab235', + indexName: 'docusaurus' + }, footer: { copyright: 'Copyright © 2018 The Manael Authors.', links: [],