Skip to content

Commit 3c9a771

Browse files
jonphippsclaude
andcommitted
perf: optimize portal cards to use build-time URL resolution
- Pre-compute all standard site URLs at build time instead of client-side - Remove client-side useDocsEnv() hook usage in favor of server-side getCurrentEnv() - URLs now hardcoded in built HTML for better performance and static optimization - Eliminates potential hydration mismatch between server and client rendering 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 83765b7 commit 3c9a771

File tree

1 file changed

+12
-5
lines changed
  • portal/src/components/HomepageFeatures

1 file changed

+12
-5
lines changed

portal/src/components/HomepageFeatures/index.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@ import Heading from '@theme/Heading';
44
import Link from '@docusaurus/Link';
55
import styles from './styles.module.css';
66
import { getSiteUrl, type SiteKey } from '@ifla/theme/config/siteConfig';
7-
import { useDocsEnv } from '@ifla/theme/hooks/useDocsEnv';
7+
import { getCurrentEnv } from '@ifla/theme/config/siteConfig.server';
88

99
type StandardItem = {
1010
title: string;
1111
code: string;
1212
description: ReactNode;
1313
siteKey: SiteKey;
1414
status: 'published' | 'draft' | 'development';
15+
href: string; // Pre-computed URL
1516
};
1617

18+
// Get current environment at build time
19+
const currentEnv = getCurrentEnv();
20+
1721
const StandardsList: StandardItem[] = [
1822
{
1923
title: 'ISBD for Manifestation (ISBDM)',
@@ -26,6 +30,7 @@ const StandardsList: StandardItem[] = [
2630
),
2731
siteKey: 'ISBDM' as SiteKey,
2832
status: 'published',
33+
href: getSiteUrl('ISBDM' as SiteKey, '', currentEnv),
2934
},
3035
{
3136
title: 'Library Reference Model (LRM)',
@@ -38,6 +43,7 @@ const StandardsList: StandardItem[] = [
3843
),
3944
siteKey: 'LRM' as SiteKey,
4045
status: 'published',
46+
href: getSiteUrl('LRM' as SiteKey, '', currentEnv),
4147
},
4248
{
4349
title: 'International Standard Bibliographic Description (ISBD)',
@@ -50,6 +56,7 @@ const StandardsList: StandardItem[] = [
5056
),
5157
siteKey: 'isbd' as SiteKey,
5258
status: 'development',
59+
href: getSiteUrl('isbd' as SiteKey, '', currentEnv),
5360
},
5461
{
5562
title: 'Functional Requirements (FR)',
@@ -62,6 +69,7 @@ const StandardsList: StandardItem[] = [
6269
),
6370
siteKey: 'FRBR' as SiteKey,
6471
status: 'development',
72+
href: getSiteUrl('FRBR' as SiteKey, '', currentEnv),
6573
},
6674
{
6775
title: 'Multilingual Dictionary of Cataloguing Terms (MulDiCat)',
@@ -74,6 +82,7 @@ const StandardsList: StandardItem[] = [
7482
),
7583
siteKey: 'muldicat' as SiteKey,
7684
status: 'development',
85+
href: getSiteUrl('muldicat' as SiteKey, '', currentEnv),
7786
},
7887
{
7988
title: 'UNIMARC',
@@ -86,13 +95,11 @@ const StandardsList: StandardItem[] = [
8695
),
8796
siteKey: 'unimarc' as SiteKey,
8897
status: 'development',
98+
href: getSiteUrl('unimarc' as SiteKey, '', currentEnv),
8999
},
90100
];
91101

92-
function StandardCard({title, code, description, siteKey, status}: StandardItem) {
93-
const currentEnv = useDocsEnv();
94-
const href = getSiteUrl(siteKey, '', currentEnv);
95-
102+
function StandardCard({title, code, description, href, status}: StandardItem) {
96103
const statusClass = status === 'published' ? styles.statusPublished :
97104
status === 'draft' ? styles.statusDraft : styles.statusDevelopment;
98105

0 commit comments

Comments
 (0)