aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2024-04-05 17:58:06 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2024-04-05 17:58:06 +0200
commit2754c468acd869394746359bbf236b6b2c9c16b6 (patch)
treecb1dbcb92f72e67b7381f309ef92f221ac2fadc4
parentUpdate profile picture (diff)
downloadblog-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.yml2
-rw-r--r--src/theme/BlogPostItem/Header/Author.tsx27
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
7import Author from '@theme-original/BlogPostItem/Header/Author';
8import type AuthorType from '@theme/BlogPostItem/Header/Author';
9import type {WrapperProps} from '@docusaurus/types';
10import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
11
12type Props = WrapperProps<typeof AuthorType>;
13
14export 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}