Skip to content

Commit

Permalink
ci: google_google analytics && update algolia devlog
Browse files Browse the repository at this point in the history
Signed-off-by: zyc <zhao.yc@botlet.io>
  • Loading branch information
zyc committed Mar 26, 2024
1 parent 15e03ba commit c4b6043
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 10 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/docsearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Sleep for 10 seconds
run: sleep 10s
shell: bash

- name: Checkout repo
uses: actions/checkout@v3

Expand Down
152 changes: 152 additions & 0 deletions DEVLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,155 @@
## Development Setup

## Development Log

#### [1、Algolia](https://www.algolia.com/)

```shell
# Sign up for an account & Create Aplication
ALGOLIA_APP_INDEX='YOUR_INDEX_NAME'
ALGOLIA_APP_ID='Application ID'
ALGOLIA_API_KEY='Admin API Key'
```

##### docusaurus.config.ts

```javascript
themeConfig: {
// .......
algolia: {
appId: process.env.ALGOLIA_APP_ID,
apiKey: process.env.ALGOLIA_API_KEY,
indexName: process.env.ALGOLIA_APP_INDEX,
}
}
```

##### Create a crawler index file in the root directory:`docsearch.json`

```json
{
// start---------
"index_name": "YOUR_INDEX_NAME",
"start_urls": ["YOUR_WEB"],
"sitemap_urls": ["YOUR_WEB"],
"stop_urls": ["/search"],
// end-----------
"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, article 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"
},
"custom_settings": {
"attributesForFaceting": [
"type",
"lang",
"language",
"version",
"docusaurus_tag"
],
"attributesToRetrieve": [
"hierarchy",
"content",
"anchor",
"url",
"url_without_anchor",
"type"
],
"attributesToHighlight": ["hierarchy", "content"],
"attributesToSnippet": ["content:10"],
"camelCaseAttributes": ["hierarchy", "content"],
"searchableAttributes": [
"unordered(hierarchy.lvl0)",
"unordered(hierarchy.lvl1)",
"unordered(hierarchy.lvl2)",
"unordered(hierarchy.lvl3)",
"unordered(hierarchy.lvl4)",
"unordered(hierarchy.lvl5)",
"unordered(hierarchy.lvl6)",
"content"
],
"distinct": true,
"attributeForDistinct": "url",
"customRanking": [
"desc(weight.pageRank)",
"desc(weight.level)",
"asc(weight.position)"
],
"ranking": [
"words",
"filters",
"typo",
"attribute",
"proximity",
"exact",
"custom"
],
"highlightPreTag": "<span class='algolia-docsearch-suggestion--highlight'>",
"highlightPostTag": "</span>",
"minWordSizefor1Typo": 3,
"minWordSizefor2Typos": 7,
"allowTyposOnNumericTokens": false,
"minProximity": 1,
"ignorePlurals": true,
"advancedSyntax": true,
"attributeCriteriaComputedByMinProximity": true,
"removeWordsIfNoResults": "allOptional",
"separatorsToIndex": "_",
"synonyms": [
["js", "javascript"],
["ts", "typescript"]
]
}
}
```

##### Two ways to run crawlers

1、Local operation

```shell
yum install -y epel-release
yum install -y jq
docker run -it --env-file=.env -e "CONFIG=$(cat docsearch.json | jq -r tostring)" algolia/docsearch-scraper
```

2、GitHub Actions

```
name: docsearch-scraper
on:
push:
branches: [main]
jobs:
scan:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Run scraper
env:
APPLICATION_ID: ${{ secrets.APPLICATION_ID }}
API_KEY: ${{ secrets.API_KEY }}
run: |
CONFIG="$(cat docsearch.json)"
docker run -i --rm \
-e APPLICATION_ID=$APPLICATION_ID \
-e API_KEY=$API_KEY \
-e CONFIG="${CONFIG}" \
algolia/docsearch-scraper
```

11 changes: 7 additions & 4 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import { themes as prismThemes } from "prism-react-renderer";

const config: Config = {
title: "Botlet.IO",
tagline:
"Break the silos between Users & Systems<br/> User-as-a-Service v.v., Service-as-a-User",
tagline: "Break the silos between Users & Systems<br/> User-as-a-Service v.v., Service-as-a-User",
favicon: "img/favicon.ico",

customFields: {
homeTitle: "",
homeDescription: "",
homeTitle: "botlet",
homeDescription: "docsbotlet",
signupUrl: process.env.SITE_SIGNUP_URL,
apiSiteUrl: process.env.API_SITE_URL,
cookieDomain: process.env.SITE_URL_DOMAIN,
Expand Down Expand Up @@ -62,6 +61,10 @@ const config: Config = {
theme: {
customCss: "./src/css/custom.css",
},
gtag: {
trackingID: process.env.GOOGLE_GTAG,
anonymizeIP: true,
},
} satisfies Preset.Options,
],
],
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"private": true,
"scripts": {
"docusaurus": "docusaurus",
"start": "cross-env NODE_ENV=production API_SITE_URL=https://localhost:3000 docusaurus start -p 4000 ",
"start": "cross-env NODE_ENV=production docusaurus start -p 4000 ",
"build": "docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
"serve": "docusaurus serve -p 4000",
"serve": "cross-env NODE_ENV=production docusaurus serve -p 4000",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
"typecheck": "tsc",
Expand All @@ -21,6 +21,7 @@
"dependencies": {
"@docusaurus/core": "3.1.1",
"@docusaurus/preset-classic": "3.1.1",
"@docusaurus/theme-common": "^3.1.1",
"@mdx-js/react": "^3.0.0",
"@reduxjs/toolkit": "^2.2.1",
"axios": "^1.6.7",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c4b6043

Please sign in to comment.