Commit 386dd42
authored
Add id slug field to metadata (#43)
## Summary
- Adds a new `id` field at the top of the YAML frontmatter in all
documents
- The `id` is generated from `beteckningSortable` in the format
`sfs-YYYY-NNN` (e.g., `sfs-2024-1000`)
- Refactors filename generation to use the id slug (filenames remain
unchanged: `sfs-2024-1000.md`)
- Updates frontmatter sorting to ensure `id` appears first
## Changes
- **`sfs_processor.py`**:
- New `create_id_slug()` function to generate clean slug from
`beteckningSortable`
- Updated `create_safe_filename()` to use id slug as input (filenames
unchanged)
- Modified frontmatter generation to include `id` field at the top
- The `id` field value matches the filename (without .md extension)
- **`formatters/sort_frontmatter.py`**:
- Added `id` to `PROPERTY_ORDER` as the first field
## Example
```yaml
---
id: sfs-2010-800
beteckning: "2010:800"
rubrik: Skollag
normtyp: Lag
...
---
```
Filename: `sfs-2010-800.md`
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 parent bd64c16 commit 386dd42
2 files changed
Lines changed: 35 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
125 | 126 | | |
126 | 127 | | |
127 | 128 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
50 | 53 | | |
51 | 54 | | |
52 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
53 | 70 | | |
54 | 71 | | |
55 | 72 | | |
56 | 73 | | |
57 | 74 | | |
58 | | - | |
59 | 75 | | |
60 | | - | |
| 76 | + | |
61 | 77 | | |
62 | | - | |
| 78 | + | |
63 | 79 | | |
64 | 80 | | |
65 | 81 | | |
| |||
207 | 223 | | |
208 | 224 | | |
209 | 225 | | |
210 | | - | |
211 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
212 | 232 | | |
213 | 233 | | |
214 | 234 | | |
| |||
348 | 368 | | |
349 | 369 | | |
350 | 370 | | |
351 | | - | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
352 | 376 | | |
| 377 | + | |
353 | 378 | | |
354 | 379 | | |
355 | 380 | | |
| |||
0 commit comments