diff options
author | Kristóf Marussy <kristof@marussy.com> | 2024-04-05 17:58:06 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2024-04-05 17:58:06 +0200 |
commit | 2754c468acd869394746359bbf236b6b2c9c16b6 (patch) | |
tree | cb1dbcb92f72e67b7381f309ef92f221ac2fadc4 | |
parent | Update profile picture (diff) | |
download | blog-2754c468acd869394746359bbf236b6b2c9c16b6.tar.gz blog-2754c468acd869394746359bbf236b6b2c9c16b6.tar.zst blog-2754c468acd869394746359bbf236b6b2c9c16b6.zip |
Fix author profile link in blog
* Use internal links whenever possible
* Use .jpg in JSON-LD for compatibility, but .webp in the website for
performance
-rw-r--r-- | blog/authors.yml | 2 | ||||
-rw-r--r-- | src/theme/BlogPostItem/Header/Author.tsx | 27 |
2 files changed, 28 insertions, 1 deletions
diff --git a/blog/authors.yml b/blog/authors.yml index 12a86d9..db3ee8b 100644 --- a/blog/authors.yml +++ b/blog/authors.yml | |||
@@ -6,5 +6,5 @@ kris: | |||
6 | name: Kristóf Marussy | 6 | name: Kristóf Marussy |
7 | title: Software engineering researcher, developer | 7 | title: Software engineering researcher, developer |
8 | url: https://marussy.com | 8 | url: https://marussy.com |
9 | image_url: 'https://marussy.com/profile.webp' | 9 | image_url: 'https://marussy.com/profile.jpg' |
10 | email: kristof@marussy.com | 10 | email: kristof@marussy.com |
diff --git a/src/theme/BlogPostItem/Header/Author.tsx b/src/theme/BlogPostItem/Header/Author.tsx new file mode 100644 index 0000000..226caee --- /dev/null +++ b/src/theme/BlogPostItem/Header/Author.tsx | |||
@@ -0,0 +1,27 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2024 Kristóf Marussy | ||
3 | * | ||
4 | * SPDX-License-Identifier: MIT | ||
5 | */ | ||
6 | |||
7 | import Author from '@theme-original/BlogPostItem/Header/Author'; | ||
8 | import type AuthorType from '@theme/BlogPostItem/Header/Author'; | ||
9 | import type {WrapperProps} from '@docusaurus/types'; | ||
10 | import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; | ||
11 | |||
12 | type Props = WrapperProps<typeof AuthorType>; | ||
13 | |||
14 | export default function AuthorWrapper(props: Props): JSX.Element { | ||
15 | const { siteConfig: { url } } = useDocusaurusContext(); | ||
16 | const newProps = {...props}; | ||
17 | const { author } = props; | ||
18 | if (author.url !== undefined && author.url.startsWith(url)) { | ||
19 | const newURL = author.url.substring(url.length); | ||
20 | newProps.author.url = newURL === '' ? '/' : newURL; | ||
21 | } | ||
22 | if (author.imageURL !== undefined && author.imageURL.startsWith(url)) { | ||
23 | const newImageURL = author.imageURL.substring(url.length); | ||
24 | newProps.author.imageURL = newImageURL.replace(/\.jpg$/, '.webp'); | ||
25 | } | ||
26 | return <Author {...newProps} /> | ||
27 | } | ||