Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/search implementation #5

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 43 additions & 19 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,30 @@ const config = {
respectPrefersColorScheme: false,
},

typesense: {
// Replace this with the name of your index/collection.
// It should match the "index_name" entry in the scraper's "config.json" file.
typesenseCollectionName: 'powerloom',

typesenseServerConfig: {
nodes: [
{
host: 'localhost',
port: 8108,
protocol: 'http',
},
],
apiKey: 'xyz',
},

// Optional: Typesense search parameters: https://typesense.org/docs/0.24.0/api/search.html#search-parameters
typesenseSearchParameters: {},

// Optional
contextualSearch: true,
},


codeblock: {
showGithubLink: true,
githubLinkLabel: 'View on GitHub',
Expand Down Expand Up @@ -167,32 +191,32 @@ const config = {

}),

plugins: [
[
"docusaurus-plugin-openapi-docs",
{
id: "openapi",
docsPluginId: "classic",
config: {
poolerdocs: {
specPath: "examples/core_api.yaml",
outputDir: "docs/build-with-powerloom/snapshotter-node/core-api",
downloadUrl:
"https://raw.githubusercontent.com/PowerLoom/docs/main/examples/core_api.yaml",
sidebarOptions: {
groupPathsBy: "tag",
categoryLinkSource: "tag",
},
plugins: [
[
"docusaurus-plugin-openapi-docs",
{
id: "openapi",
docsPluginId: "classic",
config: {
poolerdocs: {
specPath: "examples/core_api.yaml",
outputDir: "docs/build-with-powerloom/snapshotter-node/core-api",
downloadUrl:
"https://raw.githubusercontent.com/PowerLoom/docs/main/examples/core_api.yaml",
sidebarOptions: {
groupPathsBy: "tag",
categoryLinkSource: "tag",
},
},
},
],
},
],
],

themes: [
'docusaurus-theme-github-codeblock',
'docusaurus-theme-openapi-docs'

'docusaurus-theme-openapi-docs',
'docusaurus-theme-search-typesense',
]
};

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"docusaurus-plugin-openapi-docs": "2.0.0",
"docusaurus-theme-github-codeblock": "^1.1.4",
"docusaurus-theme-openapi-docs": "2.0.0",
"docusaurus-theme-search-typesense": "^0.15.0-0",
"prism-react-renderer": "^1.3.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
9 changes: 9 additions & 0 deletions typesense/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Enabling TypeSense Search on Developer Docs:

1. Install TypeSense: https://typesense.org/docs/guide/install-typesense.html#option-2-local-machine-self-hosting
2. Rename .env and change the values to real ones
3. cd to typesense
4. Scrape Data to TypeSense node: https://typesense.org/docs/guide/docsearch.html#step-1-set-up-docsearch-scraper
5. Setup CI: https://typesense.org/docs/guide/docsearch.html#integrate-with-ci-deploy-it-to-a-server

We can plan to use TypeSense Cloud / Self host this!
50 changes: 50 additions & 0 deletions typesense/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"index_name": "powerloom",
"start_urls": [
"https://docs.powerloom.io"
],
"sitemap_urls": [
"https://docs.powerloom.io/sitemap.xml"
],
"sitemap_alternate_links": true,
"stop_urls": [
"/tests"
],
"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"
},
"strip_chars": " .,;:#",
"custom_settings": {
"separatorsToIndex": "_",
"attributesForFaceting": [
"language",
"version",
"type",
"docusaurus_tag"
],
"attributesToRetrieve": [
"hierarchy",
"content",
"anchor",
"url",
"url_without_anchor",
"type"
]
},
"conversation_id": [
"833762294"
],
"nb_hits": 46250
}
4 changes: 4 additions & 0 deletions typesense/env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
TYPESENSE_API_KEY=xyz
TYPESENSE_HOST=host.docker.internal
TYPESENSE_PORT=8108
TYPESENSE_PROTOCOL=http
Loading