Skip to content

Commit 29c6e82

Browse files
committed
feat: enhance homepage navigation and image loading
- Replaced anchor tags with Docusaurus Link components for better client-side navigation. - Added eager loading and sync decoding attributes to icons for improved performance. - Implemented image preloading in the HomepageFeatures component to reduce flashing during navigation. - Updated CSS for list container links to improve styling and hover effects.
1 parent 660ca31 commit 29c6e82

File tree

3 files changed

+39
-10
lines changed

3 files changed

+39
-10
lines changed

docusaurus.config.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,10 @@ const config = {
9494
}
9595
],
9696
createRedirects(existingPath) {
97-
// Handle trailing slash normalization and ensure proper routing
98-
if (existingPath.includes('/docs/')) {
97+
// Handle trailing slash normalization for client-side routing
98+
if (existingPath.includes('/docs/') && !existingPath.endsWith('/')) {
9999
return [
100-
existingPath.replace('/docs/', '/docs'),
101-
existingPath.replace('/docs', '/docs'),
100+
existingPath + '/',
102101
];
103102
}
104103
return undefined;

src/components/homepage/homeNavBoxes.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import React from 'react';
1+
import React, { useEffect } from 'react';
22
import clsx from 'clsx';
3+
import Link from '@docusaurus/Link';
34
import styles from './homeNavBoxes.module.css';
45

56
const FeatureList = [
@@ -113,18 +114,22 @@ const FeatureList = [
113114

114115
function FeatureItem({url, text}){
115116
return (
116-
<li><a className={styles.listContainerLink} href={url}>{text}</a></li>
117+
<li><Link className={styles.listContainerLink} to={url}>{text}</Link></li>
117118
);
118119
}
119120

120121

121122
function Feature({title, icon, items }) {
122-
123-
124123
return (
125124
<article className={clsx('col col--4')}>
126125
<div className={styles.homecard}>
127-
<img src={icon} className={styles.homeIcon}></img>
126+
<img
127+
src={icon}
128+
className={styles.homeIcon}
129+
loading="eager"
130+
decoding="sync"
131+
alt={`${title} icon`}
132+
/>
128133
<h2>{title}</h2>
129134
<div className={styles.listContainer}>
130135
<ul>
@@ -134,14 +139,21 @@ function Feature({title, icon, items }) {
134139
</ul>
135140
</div>
136141
</div>
137-
138142
</article>
139143
);
140144
}
141145

142146

143147

144148
export default function HomepageFeatures() {
149+
useEffect(() => {
150+
// Preload all images to prevent flashing during navigation
151+
FeatureList.forEach(feature => {
152+
const img = new Image();
153+
img.src = feature.icon;
154+
});
155+
}, []);
156+
145157
return (
146158
<section className={styles.features}>
147159
<ul className={styles.grid3col}>

src/components/homepage/homeNavBoxes.module.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,30 @@ html[data-theme='dark'] .homecard h2 {
134134
text-decoration: underline;
135135
}
136136

137+
.listContainerLink {
138+
display: block;
139+
padding: 0.25rem 0;
140+
border-radius: 4px;
141+
transition: background-color 0.2s ease, color 0.2s ease;
142+
text-decoration: none;
143+
font-weight: 600;
144+
}
145+
146+
.listContainerLink:hover {
147+
background-color: rgba(0, 123, 255, 0.1);
148+
text-decoration: none;
149+
}
150+
137151
.homeIcon {
138152
width: 32px;
139153
height: 32px;
140154
border-radius: 0 !important;
141155
/* margin: 12px 0 4px 16px; */
142156
filter: brightness(0.9);
157+
will-change: filter;
158+
transition: filter 0.3s ease;
159+
image-rendering: crisp-edges;
160+
backface-visibility: hidden;
143161
}
144162

145163
html[data-theme='light'] .homeIcon {

0 commit comments

Comments
 (0)