Skip to content

Commit

Permalink
chore: use custom env for meilisearch
Browse files Browse the repository at this point in the history
  • Loading branch information
albttx committed Mar 20, 2024
1 parent 39788c8 commit 029bd9c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions docusaurus/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ const config = {
locales: ["en"],
},

customFields: {
meilisearchURL: process.env.MEILISEARCH_URL || 'localhost:7700',
meilisearchApiKey: process.env.MEILISEARCH_API_KEY || 'masterKey',
meilisearchIndexUid: process.env.MEILISEARCH_INDEX_UID || 'dev'
},

scripts: [
{
// 100% privacy-first analytics
Expand Down
17 changes: 14 additions & 3 deletions docusaurus/src/theme/SearchBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,26 @@ import React, { useEffect } from "react";
// import "./style.css";
import "meilisearch-docsearch/css";

import useDocusaurusContext from '@docusaurus/useDocusaurusContext';


export default function Component() {
const { siteConfig } = useDocusaurusContext();

const {
meilisearchURL,
meilisearchApiKey,
meilisearchIndexUid,
} = siteConfig.customFields

useEffect(() => {
const lang = document.querySelector("html").lang || "en";

const docsearch = require("meilisearch-docsearch").default;
const destroy = docsearch({
host: "http://localhost:7700",
apiKey: "xxx",
indexUid: "dev",
host: meilisearchURL,
apiKey: meilisearchApiKey,
indexUid: meilisearchIndexUid,
container: "#docsearch",
// searchParams: {filter: [`lang = ${lang}`]},
});
Expand Down

0 comments on commit 029bd9c

Please sign in to comment.