mirror of
https://github.com/DefectingCat/DefectingCat.github.io
synced 2025-07-15 16:51:37 +00:00
Update algolia search
This commit is contained in:
@ -20,20 +20,16 @@ export const getHeadings = (source: string) => {
|
||||
const regex = /<h2 id="(.*?)">(.*?)<\/h2>/g;
|
||||
const linkRegx = /id="(.*?)"/;
|
||||
|
||||
if (source.match(regex)) {
|
||||
return source.match(regex)?.map((heading) => {
|
||||
const headingText = heading
|
||||
.replace(/<h2 id="(.*?)">/, '')
|
||||
.replace(/<\/h2>/, '');
|
||||
return source.match(regex)?.map((heading) => {
|
||||
const headingText = heading
|
||||
.replace(/<h2 id="(.*?)">/, '')
|
||||
.replace(/<\/h2>/, '');
|
||||
|
||||
const link = '#' + heading.match(linkRegx)?.[1];
|
||||
const link = '#' + heading.match(linkRegx)?.[1];
|
||||
|
||||
return {
|
||||
text: headingText,
|
||||
link,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return [];
|
||||
return {
|
||||
text: headingText,
|
||||
link,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user