Skip to content

Commit f6eaaca

Browse files
committed
Add search using Typesense
1 parent e5d60a1 commit f6eaaca

8 files changed

Lines changed: 7198 additions & 3820 deletions

File tree

.env.typesense.sample

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Example Local Docker:
2+
#
3+
# For Local Docker, the TYPESENSE_API_KEY and TYPESENSE_SEARCH_API_KEY
4+
# are the same as there's only one key to the local Typesense instance.
5+
#
6+
# TYPESENSE_API_KEY=local_typesense_admin
7+
# TYPESENSE_HOST=host.docker.internal
8+
# TYPESENSE_PORT=8108
9+
# TYPESENSE_PROTOCOL=http
10+
# TYPESENSE_SEARCH_API_KEY=local_typesense_admin
11+
12+
# Example Typesense Cloud:
13+
#
14+
# For Typesense Cloud, the TYPESENSE_API_KEY needs to have write access
15+
# to the Typesense cluster because it's used by the scraper to index the
16+
# content, while the TYPESENSE_SEARCH_API_KEY needs to have read-only
17+
# access to the Typesense cluster because it's used by the browser to
18+
# perform search queries.
19+
#
20+
# TYPESENSE_API_KEY=<ADMIN_TYPESENSE_API_KEY>
21+
# TYPESENSE_HOST=<TYPESENSE_CLUSTER.a1.typesense.net>
22+
# TYPESENSE_PORT=443
23+
# TYPESENSE_PROTOCOL=https
24+
# TYPESENSE_SEARCH_API_KEY=<READ_ONLY_TYPESENSE_API_KEY>
25+
26+
TYPESENSE_API_KEY=
27+
TYPESENSE_HOST=
28+
TYPESENSE_PORT=
29+
TYPESENSE_PROTOCOL=
30+
TYPESENSE_SEARCH_API_KEY=

.github/workflows/deploy.docusaurus.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
pull-requests: write
1616

1717
steps:
18-
- name: Checkout code
18+
- name: Checkout Code
1919
uses: actions/checkout@v3
2020

2121
- name: Setup Node.js
@@ -24,11 +24,16 @@ jobs:
2424
node-version: 18
2525
cache: npm
2626

27-
- name: Install dependencies
27+
- name: Install Dependencies
2828
run: npm ci
2929

3030
- name: Build
3131
run: npm run build
32+
env:
33+
TYPESENSE_HOST: ${{ secrets.TYPESENSE_HOST }}
34+
TYPESENSE_PORT: 443
35+
TYPESENSE_PROTOCOL: https
36+
TYPESENSE_SEARCH_API_KEY: ${{ secrets.TYPESENSE_SEARCH_API_KEY }}
3237

3338
- name: Publish to Cloudflare Pages
3439
id: cloudflare-pages
@@ -39,7 +44,16 @@ jobs:
3944
projectName: topper-docs
4045
directory: build
4146

42-
- name: Add comment
47+
- name: Index Docs in Typesense
48+
if: github.ref == 'refs/heads/master'
49+
run: npm run index
50+
env:
51+
TYPESENSE_API_KEY: ${{ secrets.TYPESENSE_API_KEY }}
52+
TYPESENSE_HOST: ${{ secrets.TYPESENSE_HOST }}
53+
TYPESENSE_PORT: 443
54+
TYPESENSE_PROTOCOL: https
55+
56+
- name: Add Comment
4357
uses: mshick/add-pr-comment@v2
4458
with:
4559
message: |

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
/build
2-
.docusaurus
31
.cache-loader
2+
.docusaurus
3+
.env.typesense
4+
/build
5+
/typesense-data
46
node_modules

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# topper-docs
22

3-
Public developer documentation for business users integrating with topper, built using [Docusaurus](https://docusaurus.io/).
3+
Public developer documentation for business users integrating with Topper, built using [Docusaurus](https://docusaurus.io/).
44

5-
## Running locally
5+
## Running Locally
66

77
```sh
88
npm install

docusaurus.config.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ const config = {
99
locales: ['en']
1010
},
1111
onBrokenLinks: 'throw',
12-
onBrokenMarkdownLinks: 'warn',
12+
markdown: {
13+
hooks: {
14+
onBrokenMarkdownLinks: 'warn'
15+
}
16+
},
1317
presets: [
1418
[
1519
'classic',
@@ -44,10 +48,23 @@ const config = {
4448
darkTheme: darkCodeTheme,
4549
theme: lightCodeTheme,
4650
additionalLanguages: ['java', "go", "python", "php"]
51+
},
52+
typesense: {
53+
contextualSearch: true,
54+
typesenseCollectionName: 'topper_docs', // Must match `index_name` in `typesense-docsearch-config.json`.
55+
typesenseServerConfig: {
56+
apiKey: process.env.TYPESENSE_SEARCH_API_KEY ?? 'local_typesense_admin',
57+
nodes: [{
58+
host: process.env.TYPESENSE_HOST ?? 'localhost',
59+
port: parseInt(process.env.TYPESENSE_PORT) || 8108,
60+
protocol: process.env.TYPESENSE_PROTOCOL ?? 'http'
61+
}],
62+
}
4763
}
4864
},
49-
title: 'Topper - Developer docs',
50-
url: 'https://docs.topperpay.com'
65+
themes: ['docusaurus-theme-search-typesense'],
66+
title: 'Topper - Developer Docs',
67+
url: process.env.TOPPER_DOCS_URL ?? 'https://docs.topperpay.com'
5168
};
5269

5370
module.exports = config;

0 commit comments

Comments
 (0)