Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.
Open
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
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ ALGOLIA_SEARCH_ENABLED=false
# if ALGOLIA_SEARCH_ENABLED is true, you need to fill in these environment variables
ALGOLIA_APP_ID=
ALGOLIA_API_KEY=
ALGOLIA_INDEX_NAME=
SITE_URL=
80 changes: 72 additions & 8 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,80 @@ const config = {
algolia: {
appId: process.env.ALGOLIA_APP_ID,
apiKey: process.env.ALGOLIA_API_KEY,
indexName: process.env.ALGOLIA_INDEX_NAME,
indexName: "scaffoldstark",
rateLimit: 8,
maxDepth: 10,
startUrls: [`${process.env.SITE_URL}/`],
sitemaps: [`${process.env.SITE_URL}/sitemap.xml`],
ignoreCanonicalTo: true,
discoveryPatterns: [`${process.env.SITE_URL}/**`],
contextualSearch: true,
externalUrlRegex: "external\\.com|domain\\.com",
replaceSearchResultPathname: {
from: "/docs/",
to: "/",
actions: [
{
indexName: "scaffoldstark",
pathsToMatch: [`${process.env.SITE_URL}/**`],
recordExtractor: ({ $, helpers }) => {
// priority order: deepest active sub list header -> navbar active item -> 'Documentation'
const lvl0 =
$(".menu__link.menu__link--sublist.menu__link--active, .navbar__item.navbar__link--active")
.last()
.text() || "Documentation";

return helpers.docsearch({
recordProps: {
lvl0: {
selectors: "",
defaultValue: lvl0,
},
lvl1: ["header h1", "article h1"],
lvl2: "article h2",
lvl3: "article h3",
lvl4: "article h4",
lvl5: "article h5, article td:first-child",
lvl6: "article h6",
content: "article p, article li, article td:last-child",
},
indexHeadings: true,
aggregateContent: true,
recordVersion: "v3",
});
},
},
],
initialIndexSettings: {
scaffoldstark: {
attributesForFaceting: ["type", "lang", "language", "version", "docusaurus_tag"],
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",
separatorsToIndex: "_",
},
},
searchParameters: {},
searchPagePath: "search",
insights: false,
},
}
: {}),
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"postinstall": "shx cp -n .env.example .env"
},
"dependencies": {
"@docsearch/js": "3",
"@docusaurus/core": "2.4.0",
"@docusaurus/preset-classic": "2.4.0",
"@mdx-js/react": "^1.6.22",
Expand Down
Loading