mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-16 00:06:11 +02:00
refactor: enable a few TS flags (#6852)
* refactor: enable a few TS flags * refactor * revert to working version * fix * better * change
This commit is contained in:
parent
9f925a42bf
commit
4db0c620de
71 changed files with 210 additions and 174 deletions
|
@ -139,10 +139,10 @@ export function parseBlogFileName(
|
|||
if (dateFilenameMatch) {
|
||||
const {folder, text, date: dateString} = dateFilenameMatch.groups!;
|
||||
// Always treat dates as UTC by adding the `Z`
|
||||
const date = new Date(`${dateString}Z`);
|
||||
const slugDate = dateString.replace(/-/g, '/');
|
||||
const slug = `/${slugDate}/${folder}${text}`;
|
||||
return {date, text, slug};
|
||||
const date = new Date(`${dateString!}Z`);
|
||||
const slugDate = dateString!.replace(/-/g, '/');
|
||||
const slug = `/${slugDate}/${folder!}${text!}`;
|
||||
return {date, text: text!, slug};
|
||||
}
|
||||
const text = blogSourceRelative.replace(/(?:\/index)?\.mdx?$/, '');
|
||||
const slug = `/${text}`;
|
||||
|
|
|
@ -307,7 +307,7 @@ export default async function pluginContentBlog(
|
|||
({
|
||||
content: {
|
||||
__import: true,
|
||||
path: blogItemsToMetadata[postID].source,
|
||||
path: blogItemsToMetadata[postID]!.source,
|
||||
query: {
|
||||
truncated: true,
|
||||
},
|
||||
|
@ -359,7 +359,7 @@ export default async function pluginContentBlog(
|
|||
modules: {
|
||||
sidebar: aliasedSource(sidebarProp),
|
||||
items: items.map((postID) => {
|
||||
const blogPostMetadata = blogItemsToMetadata[postID];
|
||||
const blogPostMetadata = blogItemsToMetadata[postID]!;
|
||||
return {
|
||||
content: {
|
||||
__import: true,
|
||||
|
|
|
@ -19,8 +19,9 @@ function translateListPage(
|
|||
items,
|
||||
metadata: {
|
||||
...metadata,
|
||||
blogTitle: translations.title.message,
|
||||
blogDescription: translations.description.message,
|
||||
blogTitle: translations.title?.message ?? page.metadata.blogTitle,
|
||||
blogDescription:
|
||||
translations.description?.message ?? page.metadata.blogDescription,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
@ -52,10 +53,14 @@ export function translateContent(
|
|||
content: BlogContent,
|
||||
translationFiles: TranslationFiles,
|
||||
): BlogContent {
|
||||
const [{content: optionsTranslations}] = translationFiles;
|
||||
if (translationFiles.length === 0) {
|
||||
return content;
|
||||
}
|
||||
const {content: optionsTranslations} = translationFiles[0]!;
|
||||
return {
|
||||
...content,
|
||||
blogSidebarTitle: optionsTranslations['sidebar.title'].message,
|
||||
blogSidebarTitle:
|
||||
optionsTranslations['sidebar.title']?.message ?? content.blogSidebarTitle,
|
||||
blogListPaginated: translateListPage(
|
||||
content.blogListPaginated,
|
||||
optionsTranslations,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue