Skip to content

Commit

Permalink
Merge pull request #200 from AndreyTheWeb/algolia-docs-search
Browse files Browse the repository at this point in the history
feat: add algolia docs search
  • Loading branch information
debabin authored Jul 4, 2024
2 parents 3eb0db5 + 5d0f72e commit 99ced0d
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ import { getHookItems } from '../src/utils';

export default async () => {
const hookItems = await getHookItems();
const sidebarHookItems = hookItems.reduce<DefaultTheme.SidebarItem[]>((categoryItems, hookItem) => {
const category = categoryItems.find((group) => group.text === hookItem.category);
const sidebarHookItems = hookItems.reduce<DefaultTheme.SidebarItem[]>(
(categoryItems, hookItem) => {
const category = categoryItems.find((group) => group.text === hookItem.category);

if (!category) {
categoryItems.push({ text: hookItem.category, items: [hookItem] });
} else {
category.items!.push(hookItem);
}
if (!category) {
categoryItems.push({ text: hookItem.category, items: [hookItem] });
} else {
category.items!.push(hookItem);
}

return categoryItems;
}, []);
return categoryItems;
},
[]
);
const homePageFeatures = hookItems.map((item) => ({
title: item.text,
details: item.description,
Expand All @@ -36,7 +39,7 @@ export default async () => {
},
transformPageData: (pageData) => {
if (pageData.relativePath === 'index.md') {
pageData.frontmatter.features = homePageFeatures
pageData.frontmatter.features = homePageFeatures;
}

if (pageData.relativePath.includes('hooks')) {
Expand All @@ -58,9 +61,6 @@ export default async () => {
label: 'English',
lang: 'en',
themeConfig: {
search: {
provider: 'local'
},
editLink: {
pattern: ({ filePath, params }) => {
if (filePath.includes('hooks') && params?.name) {
Expand Down Expand Up @@ -105,6 +105,14 @@ export default async () => {
// }
},
themeConfig: {
search: {
provider: 'algolia',
options: {
appId: '62LROXAB1F',
apiKey: 'c1ff07348583383446ca32068eb1300f',
indexName: 'siberiacancodeio'
}
},
socialLinks: [
{ icon: 'github', link: 'https://github.com/siberiacancode/reactuse' },
{ icon: 'npm', link: 'https://www.npmjs.com/package/@siberiacancode/reactuse' },
Expand Down

0 comments on commit 99ced0d

Please sign in to comment.