|
1 | | -# Current Site Scaffolding Plan |
2 | | -**IMPORTANT: Read and update this before each phase** |
| 1 | +# Current Site Scaffolding System |
| 2 | +**Status: COMPLETED AND OPERATIONAL** |
3 | 3 |
|
4 | 4 | ## Overview |
5 | | -The scaffolding system consists of two main scripts: |
6 | | -1. **scaffold-site.ts** - Uses `scripts/scaffold-template` directory to establish folders and static files for a new site |
7 | | -2. **generate-individual-config.ts** - Generates the docusaurus.config.ts file by: |
8 | | - - Loading a `site-config.json` file from the site directory (built from future form/wizard) |
9 | | - - Using this config data to generate a self-contained docusaurus.config.ts |
10 | | - - For re-scaffolding existing sites: store site-config.json in existing directory |
11 | | - - For new sites: store site-config.json in newly created directory |
12 | | - |
13 | | -## Phase 1: Move siteConfig.ts to Theme & Update Template Generator |
14 | | -**Move configuration logic and fix template generation:** |
15 | | - |
16 | | -1. **Move siteConfig.ts** from `libs/shared-config/src/lib/` to `packages/theme/src/config/` |
17 | | -2. **Update site-template.ts** to generate self-contained docusaurus.config.ts: |
18 | | - - Inline the SITE_CONFIG data structure directly in generated config |
19 | | - - Inline getSiteConfig function directly in generated config |
20 | | - - **Error handling**: If no DOCS_ENV, throw clear error (don't substitute) |
21 | | - - Add siteConfigMap to customFields for sister site URLs |
22 | | -3. **Add new site support** to SITE_CONFIG for testing new site scaffolding |
23 | | - |
24 | | -## Phase 2: Fix UNIMARC URL/BaseURL Resolution |
25 | | -**Update UNIMARC to use proper environment resolution:** |
26 | | - |
27 | | -1. UNIMARC is already good except for hardcoded url/baseUrl |
28 | | -2. Replace hardcoded values with environment-based resolution using DOCS_ENV |
29 | | -3. **Test using existing scripts**: `build:unimarc`, `start:unimarc`, etc. |
30 | | -4. Verify isolation and no contamination |
31 | | - |
32 | | -## Phase 3: Re-scaffold Existing Sites (Moved ahead of scaffold-site) |
33 | | -**Apply clean configs to eliminate contamination:** |
34 | | - |
35 | | -### Procedure for Each Site: |
36 | | -1. **Make a backup** of the site's current docusaurus.config.ts (e.g., `mv docusaurus.config.ts docusaurus.config.ts.backup-YYYYMMDD`) |
37 | | -2. **Read that config** to extract values and build a site-config.json |
38 | | -3. **Load that JSON file** in the generate-individual-config.ts script and generate a new docusaurus.config.ts |
39 | | -4. **Compare the generated config** to a known-good config (e.g., correct unimarc config) for structure/patterns |
40 | | -5. **Refine if needed** and then build the site using the new config |
41 | | -6. **Serve the site** and run visual regression tests: |
42 | | - - Use `pnpm test:visual-regression` with the visual-regression.spec.ts test |
43 | | - - Compare against baseline snapshots in ./tests |
44 | | -7. **Manual review** - Have user look at it and offer suggestions |
45 | | - |
46 | | -**Note**: Can rename existing docusaurus.config.ts instead of copying for backup |
47 | | - |
48 | | -### Sites to Re-scaffold: |
49 | | -1. ✅ **LRM** (Library Reference Model) - **COMPLETED** |
50 | | - - Generated site-config.json from existing config |
51 | | - - Used updated generate-individual-config.ts script |
52 | | - - Fixed import path: `@ifla/theme/config/siteConfig` (not `@ifla/theme`) |
53 | | - - Fixed navbar docId: `intro/intro` (due to folder structure) |
54 | | - - **Build successful**: `DOCS_ENV=local pnpm build:lrm --skip-nx-cache` |
55 | | - - **Server working**: `DOCS_ENV=local pnpm serve:lrm` → http://localhost:3002/LRM/ |
56 | | - - **Known issues**: Some broken links to placeholder content (expected) |
57 | | -2. **muldicat** → **isbd** → others using updated template |
58 | | -3. **Test each site individually** using their own build/serve scripts (e.g., `build:muldicat`) |
59 | | - |
60 | | -### Key Fixes for LRM Re-scaffolding: |
61 | | -- **Import path must be specific**: Use `@ifla/theme/config/siteConfig` to avoid React component loading during config phase |
62 | | -- **Document structure matters**: LRM has `intro/intro.mdx` not `intro.mdx`, so navbar needs `docId: 'intro/intro'` |
63 | | -- **Site-config.json template works**: Template in `scripts/scaffold-template/site-config.json` successfully generates configs |
64 | | - |
65 | | -## Phase 4: Enhanced Scaffold-Site Script |
66 | | -**Complete the scaffolding system:** |
67 | | - |
68 | | -1. **Hybrid approach**: Copy from scaffold-template directory + generate clean config |
69 | | -2. **Support both**: re-scaffolding existing sites AND creating entirely new sites |
70 | | -3. **Leverage existing infrastructure**: Use testsite pattern and existing package.json scripts |
71 | | - |
72 | | -## Key Points: |
73 | | -- ✅ Move siteConfig to theme (eliminate shared-config dependency) |
74 | | -- ✅ Generate completely self-contained configs (no imports) |
75 | | -- ✅ Backup existing configs before re-scaffolding |
76 | | -- ✅ Test each site with its own scripts |
77 | | -- ✅ Handle new sites in SITE_CONFIG for testing |
78 | | -- ✅ Error if DOCS_ENV missing (don't substitute) |
79 | | - |
80 | | -## Progress Tracking: |
81 | | -- [x] Phase 1: Move siteConfig & Update Template |
82 | | - - ✅ Moved siteConfig.ts from shared-config to theme |
83 | | - - ✅ Added test site support (testsite, newtest) |
84 | | - - ✅ Updated individualConfigTemplate to be self-contained (inline SITE_CONFIG) |
85 | | - - ✅ Added siteConfigMap to customFields |
86 | | - - ✅ Updated footer Portal link to use siteConfigMap |
87 | | - - ✅ Built theme successfully |
88 | | -- [x] Phase 2: Fix UNIMARC |
89 | | - - ✅ Generated new self-contained config using updated template |
90 | | - - ✅ Replaced hardcoded URLs with environment-based resolution |
91 | | - - ✅ Tested build with multiple environments (local, preview) |
92 | | - - ✅ Verified isolation and no contamination |
93 | | - - ✅ Fixed copyright image path to use relative URL |
94 | | -- [ ] Phase 3: Re-scaffold Sites |
95 | | -- [ ] Phase 4: Enhanced Scaffold Script |
96 | | - |
97 | | -Last Updated: 2025-01-26 |
| 5 | +The scaffolding system is a complete site generation framework that creates new IFLA standards sites with: |
| 6 | +- **Comprehensive template structure** matching the current ISBD pattern |
| 7 | +- **Dynamic configuration generation** from template files |
| 8 | +- **Rich content structure** with tabbed overview pages |
| 9 | +- **Consistent UI components** and styling |
| 10 | + |
| 11 | +### Core Components: |
| 12 | +1. **scaffold-site.ts** - Main scaffolding script using the complete template system |
| 13 | +2. **scaffold-template/** - Complete site template with all structure and components |
| 14 | +3. **site-template.ts** - Template generation logic with placeholder replacement |
| 15 | +4. **Individual site configs** - Self-contained configurations for each site |
| 16 | + |
| 17 | +## Current Scaffold Template Structure |
| 18 | + |
| 19 | +### **Template Files (Generated):** |
| 20 | +- **`docusaurus.config.ts.template`** - Complete Docusaurus configuration with placeholders |
| 21 | +- **`project.json.template`** - Nx project configuration for workspace integration |
| 22 | + |
| 23 | +### **Content Structure:** |
| 24 | +``` |
| 25 | +scripts/scaffold-template/ |
| 26 | +├── docs/ |
| 27 | +│ ├── index.mdx # Tabbed overview (Element Sets, Vocabularies, Documentation) |
| 28 | +│ ├── about.mdx # Standard background and history |
| 29 | +│ ├── assessment.mdx # Implementation guidelines |
| 30 | +│ ├── examples.mdx # Practical usage examples |
| 31 | +│ ├── glossary.mdx # Key terms and definitions |
| 32 | +│ ├── introduction.mdx # Getting started guide |
| 33 | +│ ├── elements/index.mdx # Elements overview with DocCardList |
| 34 | +│ └── terms/index.mdx # Vocabularies overview with DocCardList |
| 35 | +├── src/ |
| 36 | +│ ├── pages/ |
| 37 | +│ │ ├── index.mdx # Homepage with IFLA branding |
| 38 | +│ │ ├── manage.mdx # Management dashboard |
| 39 | +│ │ ├── rdf.tsx # RDF downloads page |
| 40 | +│ │ ├── sitemap.module.scss # Sitemap styling |
| 41 | +│ │ └── sitemap.tsx # Sitemap component |
| 42 | +│ ├── components/ |
| 43 | +│ │ ├── CompactButton.tsx # Reusable button component |
| 44 | +│ │ └── CompactButton.module.css # Button styling |
| 45 | +│ └── css/custom.scss # Site-specific styles |
| 46 | +├── blog/ |
| 47 | +│ └── authors.yml # Blog authors template |
| 48 | +├── rdf/ # RDF output directories (with .gitkeep files) |
| 49 | +│ ├── jsonld/ ├── nt/ ├── ttl/ └── xml/ |
| 50 | +├── static/img/ # Static assets (with .gitkeep) |
| 51 | +├── tsconfig.json # TypeScript configuration |
| 52 | +├── sidebars.ts # Navigation structure |
| 53 | +└── site-config.json # Configuration placeholder |
| 54 | +``` |
| 55 | + |
| 56 | +### **Key Features:** |
| 57 | + |
| 58 | +#### **Tabbed Overview Page:** |
| 59 | +- **Element Sets tab**: Shows constrained and unconstrained elements |
| 60 | +- **Value Vocabularies tab**: Displays primary, supporting, and extension vocabularies |
| 61 | +- **Documentation tab**: Links to all documentation sections |
| 62 | +- **CompactButton component**: Consistent navigation styling |
| 63 | + |
| 64 | +#### **Template Placeholders:** |
| 65 | +- `{{TITLE}}` - Site title |
| 66 | +- `{{TAGLINE}}` - Site tagline/description |
| 67 | +- `{{SITE_KEY}}` - Site identifier (e.g., 'isbd', 'lrm') |
| 68 | +- `{{SITE_KEY_LOWER}}` - Lowercase site key |
| 69 | +- `{{PORT}}` - Development server port |
| 70 | +- `{{VOCABULARY_PREFIX}}` - Vocabulary URI prefix |
| 71 | +- `{{ELEMENT_URI}}` - Element namespace URI |
| 72 | +- `{{PROJECT_NAME}}` - GitHub project name |
| 73 | +- `{{NAVBAR_TITLE}}` - Navigation bar title |
| 74 | +- `{{SITE_CODE}}` - Short site code |
| 75 | +- `{{LAST_UPDATED}}` - Last modification date |
| 76 | + |
| 77 | +## Scaffolding Workflow |
| 78 | + |
| 79 | +### **Creating a New Site:** |
| 80 | +```bash |
| 81 | +pnpm tsx scripts/scaffold-site.ts \ |
| 82 | + --siteKey=newsite \ |
| 83 | + --title="New Standard" \ |
| 84 | + --tagline="A new IFLA standard" |
| 85 | +``` |
| 86 | + |
| 87 | +### **What Happens:** |
| 88 | +1. **Validates site key** (alphanumeric, starts with letter, max 20 chars) |
| 89 | +2. **Creates directory structure** from scaffold-template |
| 90 | +3. **Generates configurations** from .template files with placeholder replacement |
| 91 | +4. **Updates package.json** with site-specific scripts |
| 92 | +5. **Creates blog content** from site configuration |
| 93 | +6. **Sets up Nx integration** with proper dependencies |
| 94 | + |
| 95 | +### **Template Integration:** |
| 96 | +- **Uses ISBD pattern**: Matches current ISBD site structure and styling |
| 97 | +- **Component consistency**: Shared CompactButton and navigation patterns |
| 98 | +- **Theme integration**: Leverages @ifla/theme components and utilities |
| 99 | +- **TypeScript compliant**: Full type safety and IntelliSense support |
| 100 | + |
| 101 | +## Component Documentation |
| 102 | + |
| 103 | +### **CompactButton Component:** |
| 104 | +```typescript |
| 105 | +interface CompactButtonProps { |
| 106 | + href: string; |
| 107 | + children: React.ReactNode; |
| 108 | +} |
| 109 | +``` |
| 110 | +- **Usage**: Navigation buttons in tabbed overview and documentation pages |
| 111 | +- **Styling**: CSS module with consistent IFLA theme styling |
| 112 | +- **Integration**: Uses @ifla/theme InLink component for site-aware navigation |
| 113 | + |
| 114 | +### **Template Configuration:** |
| 115 | +- **TypeScript compliant**: Full composite project setup with references |
| 116 | +- **Nx integration**: Proper workspace dependencies and caching |
| 117 | +- **SCSS support**: Updated from CSS to SCSS for consistency |
| 118 | +- **Port management**: Automatic port assignment and conflict resolution |
| 119 | + |
| 120 | +## Maintenance Guide |
| 121 | + |
| 122 | +### **Updating the Scaffold Template:** |
| 123 | +When making changes that should apply to all future sites: |
| 124 | + |
| 125 | +1. **Update template files** in `scripts/scaffold-template/` |
| 126 | +2. **Test template generation** with scaffold-site script |
| 127 | +3. **Verify TypeScript compilation** and lint checks |
| 128 | +4. **Update documentation** if structure changes |
| 129 | +5. **Consider impact** on existing sites (may need migration) |
| 130 | + |
| 131 | +### **Adding New Template Features:** |
| 132 | +1. **Add to scaffold-template/** with appropriate placeholders |
| 133 | +2. **Update site-template.ts** if new placeholders needed |
| 134 | +3. **Test with actual site generation** |
| 135 | +4. **Document new features** in this file and README |
| 136 | + |
| 137 | +### **Troubleshooting:** |
| 138 | +- **Build failures**: Check TypeScript configuration and theme references |
| 139 | +- **Missing components**: Ensure CompactButton and other dependencies are copied |
| 140 | +- **Port conflicts**: Use robust startup commands or port manager |
| 141 | +- **Broken links**: Verify placeholder replacement and site structure |
| 142 | + |
| 143 | +## Current Status |
| 144 | +- ✅ **Scaffold template**: Complete with ISBD-matching structure |
| 145 | +- ✅ **Component system**: CompactButton and tabbed overview implemented |
| 146 | +- ✅ **Configuration generation**: Self-contained configs with proper isolation |
| 147 | +- ✅ **Nx integration**: Full workspace support with dependencies |
| 148 | +- ✅ **TypeScript compliance**: Composite projects with proper references |
| 149 | +- ✅ **Testing integration**: Pre-commit and build validation |
| 150 | +- ✅ **Documentation**: Rich content structure with professional presentation |
| 151 | + |
| 152 | +## Active Sites Using Template: |
| 153 | +- **Portal**: Management and landing site |
| 154 | +- **ISBD**: International Standard Bibliographic Description |
| 155 | +- **ISBDM**: ISBD Manifesto |
| 156 | +- **LRM**: Library Reference Model |
| 157 | +- **FRBR**: Functional Requirements for Bibliographic Records |
| 158 | +- **MulDiCat**: Multilingual Dictionary of Cataloguing |
| 159 | +- **UniMARC**: Universal MARC format |
| 160 | +- **NewTest**: Testing site for new features |
| 161 | + |
| 162 | +Last Updated: 2025-01-30 |
0 commit comments