mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-28 08:27:03 +02:00
test: improve test coverage (#6387)
* test: improve test coverage * fix * use posixPath
This commit is contained in:
parent
a9810db1cc
commit
62223ee556
24 changed files with 463 additions and 60 deletions
|
@ -7,7 +7,7 @@
|
|||
|
||||
import {Feed, type Author as FeedAuthor, type Item as FeedItem} from 'feed';
|
||||
import type {BlogPost} from './types';
|
||||
import {normalizeUrl, mdxToHtml} from '@docusaurus/utils';
|
||||
import {normalizeUrl, mdxToHtml, posixPath} from '@docusaurus/utils';
|
||||
import type {DocusaurusConfig} from '@docusaurus/types';
|
||||
import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
|
@ -30,7 +30,7 @@ function mdxToFeedContent(mdxContent: string): string | undefined {
|
|||
}
|
||||
}
|
||||
|
||||
export async function generateBlogFeed({
|
||||
async function generateBlogFeed({
|
||||
blogPosts,
|
||||
options,
|
||||
siteConfig,
|
||||
|
@ -47,9 +47,7 @@ export async function generateBlogFeed({
|
|||
const {url: siteUrl, baseUrl, title, favicon} = siteConfig;
|
||||
const blogBaseUrl = normalizeUrl([siteUrl, baseUrl, routeBasePath]);
|
||||
|
||||
const updated =
|
||||
(blogPosts[0] && blogPosts[0].metadata.date) ||
|
||||
new Date('2015-10-25T16:29:00.000-07:00'); // weird legacy magic date
|
||||
const updated = blogPosts[0] && blogPosts[0].metadata.date;
|
||||
|
||||
const feed = new Feed({
|
||||
id: blogBaseUrl,
|
||||
|
@ -118,7 +116,10 @@ async function createBlogFeedFile({
|
|||
}
|
||||
})();
|
||||
try {
|
||||
await fs.outputFile(path.join(generatePath, feedPath), feedContent);
|
||||
await fs.outputFile(
|
||||
posixPath(path.join(generatePath, feedPath)),
|
||||
feedContent,
|
||||
);
|
||||
} catch (err) {
|
||||
throw new Error(`Generating ${feedType} feed failed: ${err}.`);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue