1+ import type { Config } from '@docusaurus/types' ;
2+ import type * as Preset from '@docusaurus/preset-classic' ;
3+ import { deepmerge } from 'deepmerge-ts' ;
4+ import {
5+ createBaseConfig ,
6+ createThemeConfig ,
7+ createIFLAPlugins ,
8+ createStandardsPresetConfig ,
9+ createStandardsFooter ,
10+ createVocabularyConfig ,
11+ createStaticDirectories ,
12+ createStandardsNavbar ,
13+ getSiteConfig ,
14+ type SiteKey ,
15+ type Environment
16+ } from '@ifla/shared-config' ;
17+ import navbarItems from './navbar' ;
18+
19+ // Determine environment from DOCS_ENV
20+ const docsEnv = process . env [ 'DOCS_ENV' ] ;
21+ if ( ! docsEnv ) {
22+ throw new Error (
23+ `❌ FATAL: DOCS_ENV environment variable is required but not set.\n` +
24+ `✅ Valid values: local, preview, development, production\n` +
25+ `💡 NX builds should load DOCS_ENV from root .env file automatically.\n` +
26+ `💡 CI/production workflows must set DOCS_ENV explicitly.`
27+ ) ;
28+ }
29+
30+ // Get configuration for this site
31+ const currentEnv = docsEnv as Environment ;
32+ const siteKey = '__CODE__' as SiteKey ; // This will be replaced during scaffolding
33+ const siteConfig = getSiteConfig ( siteKey , currentEnv ) ;
34+
35+ // Site metadata that was previously in .env files
36+ const SITE_TITLE = '__TITLE__' ;
37+ const SITE_TAGLINE = 'IFLA Standard for __TITLE__' ;
38+ const GITHUB_REPO_URL = 'https://github.com/iflastandards/standards-dev' ;
39+ const GITHUB_EDIT_URL = 'https://github.com/iflastandards/standards-dev/tree/main/standards/__CODE__/' ;
40+
41+ // Vocabulary configuration
42+ const VOCABULARY_PREFIX = 'ifla' ;
43+ const VOCABULARY_NUMBER_PREFIX = 'T' ;
44+ const VOCABULARY_PROFILE = 'vocabulary-profile.csv' ;
45+ const VOCABULARY_ELEMENT_URI = 'https://www.iflastandards.info/elements' ;
46+ const VOCABULARY_ELEMENT_PROFILE = 'elements-profile.csv' ;
47+
48+ const config : Config = deepmerge (
49+ createBaseConfig ( {
50+ title : SITE_TITLE ,
51+ tagline : SITE_TAGLINE ,
52+ url : siteConfig . url ,
53+ baseUrl : siteConfig . baseUrl ,
54+ projectName : '__CODE__' ,
55+ } ) ,
56+ {
57+ // __CODE__-specific overrides
58+ onBrokenLinks : 'warn' as const ,
59+ onBrokenMarkdownLinks : 'warn' as const ,
60+ onBrokenAnchors : 'warn' as const ,
61+ onDuplicateRoutes : 'warn' as const ,
62+
63+ // Add future config block for compliance with regression tests
64+ future : {
65+ v4 : true ,
66+ } ,
67+
68+ // Shared static directories for standards sites
69+ staticDirectories : createStaticDirectories ( 'standard' ) ,
70+
71+ customFields : {
72+ // Current environment for client-side components
73+ environment : currentEnv ,
74+ // Environment for site URL generation
75+ docsEnv : currentEnv ,
76+ // Function to get site config for any site in current environment
77+ siteConfig : ( toSiteKey : SiteKey ) => getSiteConfig ( toSiteKey , currentEnv ) ,
78+ // __CODE__-specific vocabulary configuration
79+ vocabularyDefaults : createVocabularyConfig ( {
80+ prefix : VOCABULARY_PREFIX ,
81+ numberPrefix : VOCABULARY_NUMBER_PREFIX ,
82+ profile : VOCABULARY_PROFILE ,
83+ elementUri : VOCABULARY_ELEMENT_URI ,
84+ elementProfile : VOCABULARY_ELEMENT_PROFILE ,
85+ } ) ,
86+ } ,
87+
88+ presets : [
89+ [
90+ 'classic' ,
91+ createStandardsPresetConfig ( {
92+ editUrl : GITHUB_EDIT_URL ,
93+ enableBlog : true ,
94+ showLastUpdateAuthor : true ,
95+ showLastUpdateTime : true ,
96+ } ) ,
97+ ] ,
98+ ] ,
99+
100+ plugins : [
101+ // IFLA standard plugins
102+ ...createIFLAPlugins ( {
103+ environment : currentEnv , // Pass environment for pure function
104+ enableLocalSearch : true ,
105+ searchConfig : {
106+ indexBlog : true , // __CODE__ has a blog
107+ language : [ 'en' ] ,
108+ } ,
109+ // imageConfig defaults are now environment-aware in the factory
110+ } ) ,
111+ ] ,
112+
113+ themeConfig : deepmerge (
114+ createThemeConfig ( {
115+ navbarTitle : '__TITLE__' ,
116+ navbarItems : createStandardsNavbar ( {
117+ title : '__TITLE__' ,
118+ customItems : navbarItems ,
119+ includeBlog : true ,
120+ includeVersionDropdown : true ,
121+ includeLocaleDropdown : true ,
122+ includeSearch : true ,
123+ } ) ,
124+ footerLinks : createStandardsFooter ( {
125+ githubUrl : GITHUB_REPO_URL ,
126+ includeRdfDownloads : true ,
127+ includeSitemap : true ,
128+ includeBlog : true ,
129+ } ) . links ,
130+ copyright : createStandardsFooter ( {
131+ githubUrl : GITHUB_REPO_URL ,
132+ } ) . copyright ,
133+ } ) ,
134+ {
135+ // __CODE__-specific theme overrides
136+ metadata : [
137+ { name : 'keywords' , content : 'ifla, library, standards, __CODE__' } ,
138+ ] ,
139+ tableOfContents : {
140+ minHeadingLevel : 2 ,
141+ maxHeadingLevel : 6 ,
142+ } ,
143+ } satisfies Partial < Preset . ThemeConfig > ,
144+ ) ,
145+ }
146+ ) ;
147+
148+ export default config ;
0 commit comments