-
Notifications
You must be signed in to change notification settings - Fork 163
[Docs] DocSearch implementation #855
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
Comments
Docus automatically displays the search bar when you correctly add runtimeConfig for algolia/docsearch. You can see it here: So you need to set the following in your export default defineNuxtConfig({
...
runtimeConfig: {
public: {
algolia: {
applicationId: "",
apiKey: "",
langAttribute: "lang",
docSearch: {
indexName: "content-nuxtjs",
},
},
},
},
...
}) When you look at If you want to style the Searchbar component, just add a It maybe possible that you have to manually install Hope it helps for now, until it is added to the documentation. |
I was able to implement DocSearch by myself for Hoppscotch Documentation. Prerequisite:Install Step 1: Get DocSearch access.Apply for DocSearch access → | Read Algolia DocSearch Documentation → Once you get DocSearch access, you should now have an Algolia DocSearch app in your Algolia Dashboard. DocSearch comes with an active Algolia Crawler instance as well. From the Algolia Crawler Dashboard > Editor, you can edit the Crawler configuration to fetch the markdown/html data from Docus deployment URL periodically. Here's the Crawler configuration I used to fetch data from our Docus deployment URL
Algolia Crawler Dashboard > Editor: new Crawler({
rateLimit: 8,
maxDepth: 10,
startUrls: ["https://docs.hoppscotch.io"],
renderJavaScript: false,
sitemaps: [],
ignoreCanonicalTo: false,
discoveryPatterns: ["https://docs.hoppscotch.io/**"],
schedule: "at 15:52 on Monday",
actions: [
{
indexName: "hoppscotch",
pathsToMatch: ["https://docs.hoppscotch.io/**"],
recordExtractor: ({ helpers }) => {
return helpers.docsearch({
recordProps: {
lvl1: ["header h1", "article h1", "main h1", "h1", "head > title"],
content: ["article p, article li", "main p, main li", "p, li"],
lvl0: {
selectors: "",
defaultValue: "Documentation",
},
lvl2: ["article h2", "main h2", "h2"],
lvl3: ["article h3", "main h3", "h3"],
lvl4: ["article h4", "main h4", "h4"],
lvl5: ["article h5", "main h5", "h5"],
lvl6: ["article h6", "main h6", "h6"],
},
aggregateContent: true,
recordVersion: "v3",
});
},
},
],
initialIndexSettings: {
hoppscotch: {
attributesForFaceting: ["type", "lang"],
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",
},
},
appId: "xxxxxxxxxx",
apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
}); Once you get your Docus deployment indexed by Crawler, get your Algolia App's search API key, application ID, and Index name ready for step 2.
Step 2: Add environment variables in the
|
I couldn't find a guide or example on how to implement DocSearch in Docus.
DocSearch was introduced in #22 but no documentation on how to implement the feature.
I'd appreciate if anyone can share any resources that'll help users to integrate DocSearch.
The text was updated successfully, but these errors were encountered: