| 143 | |
| 144 | /** Sync loader for use in source.ts (same pattern as compareSource). */ |
| 145 | export function loadFeatureSourceSync(): FeatureData[] { |
| 146 | try { |
| 147 | const files = readdirSync(contentDir); |
| 148 | return files |
| 149 | .filter((file) => file.endsWith('.json')) |
| 150 | .map((file) => { |
| 151 | const slug = file.replace('.json', ''); |
| 152 | const filePath = join(contentDir, file); |
| 153 | const fileContents = readFileSync(filePath, 'utf8'); |
| 154 | const data = JSON.parse(fileContents) as Omit<FeatureData, 'url'>; |
| 155 | return { ...data, url: `/features/${slug}` }; |
| 156 | }); |
| 157 | } catch (error) { |
| 158 | if ((error as NodeJS.ErrnoException).code === 'ENOENT') return []; |
| 159 | console.error('Error loading feature source:', error); |
| 160 | return []; |
| 161 | } |
| 162 | } |