fix: avoid sending blog post text twice in data payload (#12379)

pull/12633/head
Rich Harris 7 months ago committed by GitHub
parent 89b7b7fce6
commit 3abb41cc3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -122,8 +122,7 @@ export async function get_sections(markdown) {
title: 'Root',
slug: 'root',
sections: [],
breadcrumbs: [''],
text: ''
breadcrumbs: ['']
});
let currentNodes = [root];
@ -140,8 +139,7 @@ export async function get_sections(markdown) {
title: text,
slug,
sections: [],
breadcrumbs: [...currentNodes[level].breadcrumbs, text],
text: ''
breadcrumbs: [...currentNodes[level].breadcrumbs, text]
};
// Add the new node to the tree
@ -152,9 +150,6 @@ export async function get_sections(markdown) {
// Prepare for potential children of the new node
currentNodes = currentNodes.slice(0, level + 1);
currentNodes.push(newNode);
} else if (line.trim() !== '') {
// Add non-heading line to the text of the current section
currentNodes[currentNodes.length - 1].text += line + '\n';
}
}

@ -6,7 +6,6 @@ export interface Section {
// Currently, we are only going with 2 level headings, so this will be undefined. In future, we may want to support 3 levels, in which case this will be a list of sections
sections?: Section[];
breadcrumbs: string[];
text: string;
}
export type Category = {

Loading…
Cancel
Save