mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-21 21:16:59 +02:00
fix: fix a lot of declaration semantic errors (#7194)
This commit is contained in:
parent
b154318c28
commit
7f06857e46
8 changed files with 62 additions and 61 deletions
|
@ -7,11 +7,7 @@
|
|||
|
||||
import {Feed, type Author as FeedAuthor, type Item as FeedItem} from 'feed';
|
||||
import type {BlogPost} from './types';
|
||||
import {
|
||||
normalizeUrl,
|
||||
mapAsyncSequential,
|
||||
readOutputHTMLFile,
|
||||
} from '@docusaurus/utils';
|
||||
import {normalizeUrl, readOutputHTMLFile} from '@docusaurus/utils';
|
||||
import {load as cheerioLoad} from 'cheerio';
|
||||
import type {DocusaurusConfig} from '@docusaurus/types';
|
||||
import path from 'path';
|
||||
|
@ -61,46 +57,48 @@ async function generateBlogFeed({
|
|||
return {name: author.name, link: author.url, email: author.email};
|
||||
}
|
||||
|
||||
await mapAsyncSequential(blogPosts, async (post) => {
|
||||
const {
|
||||
id,
|
||||
metadata: {
|
||||
await Promise.all(
|
||||
blogPosts.map(async (post) => {
|
||||
const {
|
||||
id,
|
||||
metadata: {
|
||||
title: metadataTitle,
|
||||
permalink,
|
||||
date,
|
||||
description,
|
||||
authors,
|
||||
tags,
|
||||
},
|
||||
} = post;
|
||||
|
||||
const content = await readOutputHTMLFile(
|
||||
permalink.replace(siteConfig.baseUrl, ''),
|
||||
outDir,
|
||||
siteConfig.trailingSlash,
|
||||
);
|
||||
const $ = cheerioLoad(content);
|
||||
|
||||
const feedItem: FeedItem = {
|
||||
title: metadataTitle,
|
||||
permalink,
|
||||
id,
|
||||
link: normalizeUrl([siteUrl, permalink]),
|
||||
date,
|
||||
description,
|
||||
authors,
|
||||
tags,
|
||||
},
|
||||
} = post;
|
||||
// Atom feed demands the "term", while other feeds use "name"
|
||||
category: tags.map((tag) => ({name: tag.label, term: tag.label})),
|
||||
content: $(`#${blogPostContainerID}`).html()!,
|
||||
};
|
||||
|
||||
const content = await readOutputHTMLFile(
|
||||
permalink.replace(siteConfig.baseUrl, ''),
|
||||
outDir,
|
||||
siteConfig.trailingSlash,
|
||||
);
|
||||
const $ = cheerioLoad(content);
|
||||
// json1() method takes the first item of authors array
|
||||
// it causes an error when authors array is empty
|
||||
const feedItemAuthors = authors.map(toFeedAuthor);
|
||||
if (feedItemAuthors.length > 0) {
|
||||
feedItem.author = feedItemAuthors;
|
||||
}
|
||||
|
||||
const feedItem: FeedItem = {
|
||||
title: metadataTitle,
|
||||
id,
|
||||
link: normalizeUrl([siteUrl, permalink]),
|
||||
date,
|
||||
description,
|
||||
// Atom feed demands the "term", while other feeds use "name"
|
||||
category: tags.map((tag) => ({name: tag.label, term: tag.label})),
|
||||
content: $(`#${blogPostContainerID}`).html()!,
|
||||
};
|
||||
|
||||
// json1() method takes the first item of authors array
|
||||
// it causes an error when authors array is empty
|
||||
const feedItemAuthors = authors.map(toFeedAuthor);
|
||||
if (feedItemAuthors.length > 0) {
|
||||
feedItem.author = feedItemAuthors;
|
||||
}
|
||||
|
||||
feed.addItem(feedItem);
|
||||
});
|
||||
return feedItem;
|
||||
}),
|
||||
).then((items) => items.forEach(feed.addItem));
|
||||
|
||||
return feed;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue