From 2ddb86bc8036462e8f1e7c0744b4955fb3e7a831 Mon Sep 17 00:00:00 2001 From: Anthony Date: Thu, 18 Jan 2024 15:28:53 +0700 Subject: [PATCH] tweak transformItems --- resources/views/layouts/app-docs.blade.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/resources/views/layouts/app-docs.blade.php b/resources/views/layouts/app-docs.blade.php index 49c13ee..6f55035 100644 --- a/resources/views/layouts/app-docs.blade.php +++ b/resources/views/layouts/app-docs.blade.php @@ -160,6 +160,20 @@ class="absolute font-normal bg-white shadow overflow-hidden rounded w-24 border indexName: '{!! config("project.meta.algolia_index_name") !!}', insights: true, container: '#search', + transformItems(items) { + return items.map((item) => { + var sectionName = item.hierarchy.lvl2; + if (sectionName == null || sectionName == "") return; + var sectionId = sectionName.toLowerCase().replace(' ', '-'); + + // remove old anchor + item.url = item.url.replace(/#.*$/, ''); + + item.url = item.url + '#' + sectionId; + + return item; + }); + }, recordExtractor: ({ helpers }) => { return helpers.docsearch({ recordProps: {