diff options
Diffstat (limited to 'src/theme/Blog/Components/Author.tsx')
-rw-r--r-- | src/theme/Blog/Components/Author.tsx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/theme/Blog/Components/Author.tsx b/src/theme/Blog/Components/Author.tsx new file mode 100644 index 0000000..61f7dc7 --- /dev/null +++ b/src/theme/Blog/Components/Author.tsx | |||
@@ -0,0 +1,26 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2024 Kristóf Marussy | ||
3 | * | ||
4 | * SPDX-License-Identifier: MIT | ||
5 | */ | ||
6 | |||
7 | import Author from '@theme-original/Blog/Components/Author'; | ||
8 | import type { Props } from '@theme/Blog/Components/Author'; | ||
9 | import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; | ||
10 | |||
11 | export default function AuthorWrapper(props: Props): JSX.Element { | ||
12 | const { | ||
13 | siteConfig: { url }, | ||
14 | } = useDocusaurusContext(); | ||
15 | const newProps = { ...props }; | ||
16 | const { author } = props; | ||
17 | if (author.url !== undefined && author.url.startsWith(url)) { | ||
18 | const newURL = author.url.substring(url.length); | ||
19 | newProps.author.url = newURL === '' ? '/' : newURL; | ||
20 | } | ||
21 | if (author.imageURL !== undefined && author.imageURL.startsWith(url)) { | ||
22 | const newImageURL = author.imageURL.substring(url.length); | ||
23 | newProps.author.imageURL = newImageURL.replace(/\.jpg$/, '.webp'); | ||
24 | } | ||
25 | return <Author {...newProps} />; | ||
26 | } | ||