Skip to content

Commit

Permalink
feat: typesense search
Browse files Browse the repository at this point in the history
  • Loading branch information
yongenaelf committed Jun 20, 2024
1 parent 2ce0151 commit bf8686e
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/typesense.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- run: |
docker run -e TYPESENSE_API_KEY="${{ secrets.TYPESENSE_API_KEY }}" \
-e TYPESENSE_HOST="${{ secrets.TYPESENSE_HOST }}" \
-e TYPESENSE_HOST="typesense.test.aelf.dev" \
-e TYPESENSE_PORT=443 \
-e TYPESENSE_PROTOCOL=https \
-e "CONFIG=$(cat config/typesense.json | jq -r tostring)" typesense/docsearch-scraper:0.9.1
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,13 @@ $ GIT_USER=<Your GitHub username> yarn deploy
```

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.

### Generate search-only api key

```bash
curl 'https://typesense.test.aelf.dev/keys' \
-X POST \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{"description":"Search-only aelf-docs key.","actions": ["documents:search"], "collections": ["aelf-docs"]}'
```
15 changes: 15 additions & 0 deletions config/typesense-theme-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"typesenseCollectionName": "aelf-docs",
"typesenseServerConfig": {
"nodes": [
{
"host": "typesense.test.aelf.dev",
"port": 443,
"protocol": "https"
}
],
"apiKey": "5zqd4xhbUfewLSGk7Veev11KXZcDRy9z"
},
"typesenseSearchParameters": {},
"contextualSearch": true
}
4 changes: 3 additions & 1 deletion docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {Config} from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';
import footerLinks from "./config/footer-links.json";
import navbarLinks from "./config/navbar-links.json";
import typesenseThemeConfig from "./config/typesense-theme-config.json";

const config: Config = {
title: "AELF Docs",
Expand Down Expand Up @@ -51,7 +52,7 @@ const config: Config = {
} satisfies Preset.Options,
],
],

themes: ["docusaurus-theme-search-typesense"],
themeConfig: {
// Replace with your project's social card
image: "img/aelficon.png",
Expand Down Expand Up @@ -86,6 +87,7 @@ const config: Config = {
hideable: true, // https://docusaurus.io/docs/sidebar#hideable-sidebar
},
},
typesense: typesenseThemeConfig,
} satisfies Preset.ThemeConfig,
};

Expand Down
204 changes: 204 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@docusaurus/preset-classic": "3.4.0",
"@mdx-js/react": "^3.0.0",
"clsx": "^2.0.0",
"docusaurus-theme-search-typesense": "^0.20.0-0",
"prism-react-renderer": "^2.3.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
Expand Down

0 comments on commit bf8686e

Please sign in to comment.