browser.tsanddocusaurus.tshave overlapping functionalitydocusaurus.base.tsprovides unused factory pattern- Multiple ways to define the same configuration concepts
- Each site manually defines
vocabularyDefaultsincustomFields - ISBDM and LRM have site-specific configurations, others use generic defaults
- Should leverage
VOCABULARY_DEFAULTSfromdocusaurus.base.ts
- All standards sites have nearly identical structure (80+ lines of boilerplate)
- Repeated preset configurations (docs, blog, theme)
- Inconsistent navbar implementations
- Manual portal URL construction instead of using
getSiteUrl
- Some sites use hardcoded portal links with
process.env.NODE_ENVchecks - Missing
standardsDropdownin most sites - Inconsistent Resources dropdown implementations
browser.tsappears unused.config/docusaurus.config.tstemplate files exist but seem unused
Created packages/theme/src/config/standardSiteFactory.ts with createStandardSiteConfig() function that:
- Reduces boilerplate: 125+ lines → ~40 lines per site
- Ensures consistency: All sites get same base configuration
- Leverages existing infrastructure: Uses
VOCABULARY_DEFAULTS,getSiteUrl, etc. - Maintains flexibility: Allows site-specific customizations
- Handles complex cases: Supports custom sidebar generators, redirects, etc.
Remove redundant files:
- Eliminate
browser.ts(functionality covered bydocusaurus.ts) - Clean up unused
.config/template files - Either utilize
docusaurus.base.tsfactory or remove it
Centralize vocabulary defaults:
- Use
VOCABULARY_DEFAULTSfromdocusaurus.base.ts - Site-specific overrides only where needed
Maintain siteConfigCore.ts as source of truth:
- All site paths, URLs, and environment definitions remain in
siteConfigCore.ts - Scripts continue to import directly from
siteConfigCore.ts - Factory uses proper abstraction layers (
siteConfig.ts,siteConfig.server.ts) - Ensures consistent URL generation across all environments
Consistent navbar structure:
- All sites get
standardsDropdownautomatically - Standardized Resources dropdown with proper
getSiteUrlusage - Site-specific items merged with standard items
Proper URL generation:
- Replace hardcoded portal links with
getSiteUrl('portal', '/', currentEnv) - Environment-aware navigation across all sites
import type { Config } from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';
import {
sharedPlugins,
sharedThemes,
commonDefaults,
getSiteDocusaurusConfig,
getCurrentEnv,
type SiteKey,
type DocsEnv
} from '@ifla/theme/config';
const siteKey: SiteKey = 'LRM';
const currentEnv: DocsEnv = getCurrentEnv();
const currentSiteConfig = getSiteDocusaurusConfig(siteKey, currentEnv);
const config: Config = {
...commonDefaults(currentEnv),
url: currentSiteConfig.url,
title: 'IFLA LRM',
tagline: 'Library Reference Model',
baseUrl: currentSiteConfig.baseUrl,
projectName: 'LRM',
// ... 100+ more lines of repetitive configuration
};import { createStandardSiteConfig } from '@ifla/theme/config';
const config = createStandardSiteConfig({
siteKey: 'LRM',
title: 'IFLA LRM',
tagline: 'Library Reference Model',
projectName: 'LRM',
vocabularyDefaults: {
prefix: "lrm",
numberPrefix: "E",
profile: "lrm-values-profile.csv",
elementDefaults: {
uri: "https://www.iflastandards.info/LRM/elements",
profile: "lrm-elements-profile.csv",
}
},
editUrl: 'https://github.com/iflastandards/LRM/tree/main/',
navbar: {
items: [
{
type: 'doc',
docId: 'intro/intro',
position: 'left',
label: 'Introduction',
},
],
},
redirects: {
redirects: [],
createRedirects: (_existingPath: string) => undefined,
},
});
export default config;- 66% reduction in configuration code per site
- Single source of truth for common patterns
- Easier to update all sites simultaneously
- Consistent behavior across environments
- All sites get same base features (search, navigation, footer)
- Standardized vocabulary handling
- Proper environment-aware URL generation
- Consistent navbar and footer structure
- Less boilerplate to write and maintain
- Clear separation of site-specific vs. shared configuration
- Type-safe configuration options
- Self-documenting through interface
- Sites can still customize as needed
- Complex cases (like ISBDM) fully supported
- Gradual migration path
- Backward compatibility maintained
- ✅ Created
standardSiteFactory.ts - ✅ Updated theme exports
- ✅ Created example refactored configurations
- Migrate LRM (simplest case)
- Migrate fr, isbd, muldicat, unimarc (similar patterns)
- Test and validate functionality
- Migrate ISBDM (most complex case)
- Handle custom sidebar generation
- Validate all features work correctly
- Remove unused configuration files
- Update documentation
- Remove redundant code
The portal is intentionally different from standards sites:
- Acts as gateway for casual consumers
- Workplace for editors with management features
- Should maintain its current configuration approach
- May benefit from some shared components but needs unique features
- Local testing: Verify all sites build and run correctly
- Navigation testing: Ensure all cross-site links work in all environments
- Feature parity: Confirm refactored sites have same functionality
- Environment testing: Test localhost, preview, and production configurations
- Review and approve this improvement plan
- Test the LRM refactoring to validate the approach
- Migrate remaining simple sites one by one
- Handle ISBDM complexity with custom sidebar support
- Clean up unused files and update documentation