mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
fix(blog): apply baseUrl to relative image in blog authors (#10440)
Co-authored-by: sebastien <lorber.sebastien@gmail.com>
This commit is contained in:
parent
95880282b1
commit
02ed7d9132
7 changed files with 333 additions and 10 deletions
|
@ -9,12 +9,13 @@ import _ from 'lodash';
|
|||
import {readDataFile, normalizeUrl} from '@docusaurus/utils';
|
||||
import {Joi, URISchema} from '@docusaurus/utils-validation';
|
||||
import {AuthorSocialsSchema, normalizeSocials} from './authorsSocials';
|
||||
import {normalizeImageUrl} from './authors';
|
||||
import type {BlogContentPaths} from './types';
|
||||
import type {
|
||||
Author,
|
||||
AuthorAttributes,
|
||||
AuthorPage,
|
||||
AuthorsMap,
|
||||
AuthorWithKey,
|
||||
} from '@docusaurus/plugin-content-blog';
|
||||
|
||||
type AuthorInput = AuthorAttributes & {
|
||||
|
@ -93,12 +94,14 @@ export function checkAuthorsMapPermalinkCollisions(
|
|||
function normalizeAuthor({
|
||||
authorsBaseRoutePath,
|
||||
authorKey,
|
||||
baseUrl,
|
||||
author,
|
||||
}: {
|
||||
authorsBaseRoutePath: string;
|
||||
authorKey: string;
|
||||
baseUrl: string;
|
||||
author: AuthorInput;
|
||||
}): Author & {key: string} {
|
||||
}): AuthorWithKey {
|
||||
function getAuthorPage(): AuthorPage | null {
|
||||
if (!author.page) {
|
||||
return null;
|
||||
|
@ -114,6 +117,7 @@ function normalizeAuthor({
|
|||
...author,
|
||||
key: authorKey,
|
||||
page: getAuthorPage(),
|
||||
imageURL: normalizeImageUrl({imageURL: author.imageURL, baseUrl}),
|
||||
socials: author.socials ? normalizeSocials(author.socials) : undefined,
|
||||
};
|
||||
}
|
||||
|
@ -121,12 +125,14 @@ function normalizeAuthor({
|
|||
function normalizeAuthorsMap({
|
||||
authorsBaseRoutePath,
|
||||
authorsMapInput,
|
||||
baseUrl,
|
||||
}: {
|
||||
authorsBaseRoutePath: string;
|
||||
authorsMapInput: AuthorsMapInput;
|
||||
baseUrl: string;
|
||||
}): AuthorsMap {
|
||||
return _.mapValues(authorsMapInput, (author, authorKey) => {
|
||||
return normalizeAuthor({authorsBaseRoutePath, authorKey, author});
|
||||
return normalizeAuthor({authorsBaseRoutePath, authorKey, author, baseUrl});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -153,6 +159,7 @@ export async function getAuthorsMap(params: {
|
|||
authorsMapPath: string;
|
||||
authorsBaseRoutePath: string;
|
||||
contentPaths: BlogContentPaths;
|
||||
baseUrl: string;
|
||||
}): Promise<AuthorsMap | undefined> {
|
||||
const authorsMapInput = await getAuthorsMapInput(params);
|
||||
if (!authorsMapInput) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue