From a4146608db41055db260dfa7493753c21db4b929 Mon Sep 17 00:00:00 2001 From: jeremywu <15975785+JeremyWuuuuu@users.noreply.github.com> Date: Sat, 4 Sep 2021 10:34:58 +0800 Subject: [PATCH] fix(build): agolia indices script (#3234) --- build/build-indices.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/build/build-indices.ts b/build/build-indices.ts index 49d8b4a6b4..38246fa90a 100644 --- a/build/build-indices.ts +++ b/build/build-indices.ts @@ -30,7 +30,7 @@ const langs = { const index = client.initIndex(indexName) index.clearObjects().then(() => { const files = fg.sync(`website/docs/${lang}/*.md`) - const indices: Index[][] = [] + let indices: Index[] = [] files.forEach(file => { const regExp = new RegExp(`website\/docs\/${lang}\/(.*).md`) const pathContent = file.match(regExp) @@ -58,17 +58,14 @@ const langs = { return match }) let i = 0 - indices.push( + indices = indices.concat( matches.map(match => { const title = match[0].replace(/#{2,4}/, '').trim() - const index: Index = { - component, - title, - anchor: slugify(title), - content: (match[1] || title).replace(/<[^>]+>/g, ''), - path: path, - sort: i++, - } + const index = { component, title } as Index + index.anchor = slugify(title) + index.content = (match[1] || title).replace(/<[^>]+>/g, '') + index.path = path + index.sort = i++ return index }), )