fix(nx-dev): ensure og image is generated for all docs (#18617)

This commit is contained in:
Miroslav Jonaš 2023-08-14 17:44:16 +02:00 committed by GitHub
parent d1ffe58644
commit b749b479a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,21 +36,30 @@ const targetFolder: string = resolve(
); );
const data: { title: string; content: string; filename: string }[] = []; const data: { title: string; content: string; filename: string }[] = [];
documents.map((category) => { documents.forEach((category) => {
data.push({ data.push({
title: category.name, title: category.name,
content: category.description, content: category.description,
filename: [category.sidebarId, category.id].filter(Boolean).join('-'), filename: [category.sidebarId, category.id].filter(Boolean).join('-'),
}); });
category.itemList.map((item) => category.itemList.forEach((item) => {
data.push({ data.push({
title: item.name, title: item.name,
content: category.name, content: item.description || category.name,
filename: [category.sidebarId, category.id, item.id] filename: [category.sidebarId, category.id, item.id]
.filter(Boolean) .filter(Boolean)
.join('-'), .join('-'),
}) });
); item.itemList?.forEach((subItem) => {
data.push({
title: subItem.name,
content: subItem.description || category.name,
filename: [category.sidebarId, category.id, item.id, subItem.id]
.filter(Boolean)
.join('-'),
});
});
});
}); });
packages.map((pkg) => { packages.map((pkg) => {
data.push({ data.push({
@ -137,7 +146,7 @@ function splitLines(
if (words.length <= 1) { if (words.length <= 1) {
return words; return words;
} }
const lines = []; const lines: string[] = [];
let currentLine = words[0]; let currentLine = words[0];
for (let i = 1; i < words.length; i++) { for (let i = 1; i < words.length; i++) {