@terrymooreii/sia 2.1.5 → 2.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,557 @@
1
+ # Front Matter Reference
2
+
3
+ Front matter is YAML metadata at the beginning of your markdown files. It defines properties like title, date, tags, and more.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Basic Syntax](#basic-syntax)
8
+ - [Common Fields](#common-fields)
9
+ - [Posts](#posts)
10
+ - [Pages](#pages)
11
+ - [Notes](#notes)
12
+ - [Permalink Variables](#permalink-variables)
13
+ - [Date from Filename](#date-from-filename)
14
+ - [Draft Content](#draft-content)
15
+ - [Examples](#examples)
16
+
17
+ ---
18
+
19
+ ## Basic Syntax
20
+
21
+ Front matter is enclosed between triple dashes at the very beginning of the file:
22
+
23
+ ```yaml
24
+ ---
25
+ title: "My Post Title"
26
+ date: 2024-12-17
27
+ tags: [javascript, tutorial]
28
+ ---
29
+
30
+ Your markdown content starts here...
31
+ ```
32
+
33
+ **Important:** The front matter must be the first thing in the file with no whitespace before it.
34
+
35
+ ---
36
+
37
+ ## Common Fields
38
+
39
+ These fields work across all content types (posts, pages, notes):
40
+
41
+ | Field | Type | Description | Default |
42
+ |-------|------|-------------|---------|
43
+ | `title` | string | Content title | None (required for posts/pages) |
44
+ | `date` | date | Publication date | From filename or current date |
45
+ | `tags` | array/string | Tags for categorization | `[]` |
46
+ | `layout` | string | Template layout to use | From collection config |
47
+ | `permalink` | string | Custom URL path | From collection config |
48
+ | `draft` | boolean | Exclude from production builds | `false` |
49
+ | `excerpt` | string | Custom excerpt text | Auto-generated from content |
50
+ | `slug` | string | URL slug | From filename |
51
+ | `image` | string | Featured/social image path | None |
52
+ | `author` | string | Author name | `site.author` |
53
+ | `description` | string | Meta description | `excerpt` |
54
+
55
+ ### Field Details
56
+
57
+ #### `title`
58
+
59
+ The display title for the content:
60
+
61
+ ```yaml
62
+ title: "Getting Started with JavaScript"
63
+ title: 'Single quotes work too'
64
+ title: Plain text without quotes
65
+ ```
66
+
67
+ #### `date`
68
+
69
+ Publication date in various formats:
70
+
71
+ ```yaml
72
+ date: 2024-12-17
73
+ date: 2024-12-17T14:30:00
74
+ date: "December 17, 2024"
75
+ ```
76
+
77
+ #### `tags`
78
+
79
+ Tags can be an array or comma-separated string:
80
+
81
+ ```yaml
82
+ # Array format (recommended)
83
+ tags: [javascript, tutorial, beginner]
84
+
85
+ # YAML list format
86
+ tags:
87
+ - javascript
88
+ - tutorial
89
+ - beginner
90
+
91
+ # Comma-separated string
92
+ tags: javascript, tutorial, beginner
93
+ ```
94
+
95
+ #### `layout`
96
+
97
+ Override the default layout for this content:
98
+
99
+ ```yaml
100
+ layout: post # Uses post.njk
101
+ layout: page # Uses page.njk
102
+ layout: custom # Uses custom.njk (if you've created it)
103
+ ```
104
+
105
+ #### `permalink`
106
+
107
+ Custom URL for this content:
108
+
109
+ ```yaml
110
+ permalink: /custom-url/
111
+ permalink: /blog/2024/my-post/
112
+ permalink: /about-me/
113
+ ```
114
+
115
+ #### `excerpt`
116
+
117
+ Custom excerpt text (otherwise auto-generated from first paragraph):
118
+
119
+ ```yaml
120
+ excerpt: "A brief description of this post that appears in listings."
121
+ ```
122
+
123
+ #### `slug`
124
+
125
+ Override the URL slug (otherwise derived from filename):
126
+
127
+ ```yaml
128
+ slug: my-custom-slug
129
+ ```
130
+
131
+ #### `image`
132
+
133
+ Featured image for social sharing (Open Graph, Twitter Cards):
134
+
135
+ ```yaml
136
+ image: /images/featured.jpg
137
+ image: /images/posts/my-post-hero.png
138
+ ```
139
+
140
+ #### `author`
141
+
142
+ Override the site's default author:
143
+
144
+ ```yaml
145
+ author: "Jane Doe"
146
+ ```
147
+
148
+ #### `description`
149
+
150
+ Custom meta description (otherwise uses excerpt):
151
+
152
+ ```yaml
153
+ description: "Learn how to build modern web applications with this comprehensive guide."
154
+ ```
155
+
156
+ ---
157
+
158
+ ## Posts
159
+
160
+ Blog posts are stored in `src/posts/` (or your configured path).
161
+
162
+ ### Default Configuration
163
+
164
+ ```yaml
165
+ # From _config.yml
166
+ collections:
167
+ posts:
168
+ path: posts
169
+ layout: post
170
+ permalink: /blog/:slug/
171
+ sortBy: date
172
+ sortOrder: desc
173
+ ```
174
+
175
+ ### Typical Post Front Matter
176
+
177
+ ```yaml
178
+ ---
179
+ title: "How to Build a REST API"
180
+ date: 2024-12-17
181
+ tags: [api, nodejs, tutorial]
182
+ excerpt: "Learn how to build a RESTful API using Node.js and Express."
183
+ image: /images/posts/rest-api.jpg
184
+ ---
185
+ ```
186
+
187
+ ### Post-Specific Considerations
188
+
189
+ - Posts are sorted by date (newest first by default)
190
+ - Posts appear in the blog listing, RSS feed, and tag pages
191
+ - The `title` field is typically required for posts
192
+ - Default permalink: `/blog/:slug/`
193
+
194
+ ### Full Post Example
195
+
196
+ ```yaml
197
+ ---
198
+ title: "Complete Guide to CSS Grid"
199
+ date: 2024-12-17
200
+ tags: [css, layout, tutorial]
201
+ author: "Jane Doe"
202
+ excerpt: "Master CSS Grid with this comprehensive tutorial covering all the fundamentals."
203
+ image: /images/css-grid-cover.jpg
204
+ draft: false
205
+ permalink: /blog/css-grid-guide/
206
+ ---
207
+
208
+ Your post content here...
209
+ ```
210
+
211
+ ---
212
+
213
+ ## Pages
214
+
215
+ Static pages are stored in `src/pages/` (or your configured path).
216
+
217
+ ### Default Configuration
218
+
219
+ ```yaml
220
+ # From _config.yml
221
+ collections:
222
+ pages:
223
+ path: pages
224
+ layout: page
225
+ permalink: /:slug/
226
+ ```
227
+
228
+ ### Typical Page Front Matter
229
+
230
+ ```yaml
231
+ ---
232
+ title: "About Me"
233
+ description: "Learn more about who I am and what I do."
234
+ ---
235
+ ```
236
+
237
+ ### Page-Specific Considerations
238
+
239
+ - Pages use the `page` layout by default
240
+ - Pages don't have dates by default (though you can add one)
241
+ - Default permalink: `/:slug/` (e.g., `/about/`)
242
+ - Pages appear in the navigation (first 3 by default in most themes)
243
+
244
+ ### Full Page Example
245
+
246
+ ```yaml
247
+ ---
248
+ title: "Contact"
249
+ description: "Get in touch with me for inquiries or collaboration."
250
+ layout: page
251
+ permalink: /contact/
252
+ ---
253
+
254
+ ## Contact Me
255
+
256
+ You can reach me at...
257
+ ```
258
+
259
+ ---
260
+
261
+ ## Notes
262
+
263
+ Notes are short-form content stored in `src/notes/` (or your configured path). They're similar to tweets or status updates.
264
+
265
+ ### Default Configuration
266
+
267
+ ```yaml
268
+ # From _config.yml
269
+ collections:
270
+ notes:
271
+ path: notes
272
+ layout: note
273
+ permalink: /notes/:slug/
274
+ sortBy: date
275
+ sortOrder: desc
276
+ ```
277
+
278
+ ### Typical Note Front Matter
279
+
280
+ Notes often have minimal front matter since they're short-form:
281
+
282
+ ```yaml
283
+ ---
284
+ date: 2024-12-17T14:30:00
285
+ tags: [thought, coding]
286
+ ---
287
+
288
+ Just discovered a neat CSS trick! :sparkles:
289
+ ```
290
+
291
+ ### Note-Specific Considerations
292
+
293
+ - Notes typically don't have titles
294
+ - The first paragraph or excerpt is used as the identifier in listings
295
+ - Notes are sorted by date (newest first)
296
+ - Default permalink: `/notes/:slug/`
297
+ - Great for quick thoughts, links, or updates
298
+
299
+ ### Full Note Example
300
+
301
+ ```yaml
302
+ ---
303
+ date: 2024-12-17T09:15:00
304
+ tags: [programming, tip]
305
+ ---
306
+
307
+ TIL: You can use `console.table()` to display arrays and objects in a nice table format in the browser console. Super useful for debugging! :bulb:
308
+ ```
309
+
310
+ ---
311
+
312
+ ## Permalink Variables
313
+
314
+ Permalinks support these variables:
315
+
316
+ | Variable | Description | Example |
317
+ |----------|-------------|---------|
318
+ | `:slug` | URL slug from filename or front matter | `my-post` |
319
+ | `:year` | 4-digit year from date | `2024` |
320
+ | `:month` | 2-digit month from date | `12` |
321
+ | `:day` | 2-digit day from date | `17` |
322
+
323
+ ### Permalink Examples
324
+
325
+ ```yaml
326
+ # Default blog permalink
327
+ permalink: /blog/:slug/
328
+ # Result: /blog/my-post/
329
+
330
+ # Date-based permalink
331
+ permalink: /blog/:year/:month/:slug/
332
+ # Result: /blog/2024/12/my-post/
333
+
334
+ # Full date permalink
335
+ permalink: /:year/:month/:day/:slug/
336
+ # Result: /2024/12/17/my-post/
337
+
338
+ # Custom static permalink
339
+ permalink: /articles/javascript-guide/
340
+ # Result: /articles/javascript-guide/
341
+ ```
342
+
343
+ ### Setting Permalinks
344
+
345
+ Permalinks can be set at three levels:
346
+
347
+ 1. **In `_config.yml`** - Default for all items in a collection
348
+ 2. **In front matter** - Override for a specific item
349
+
350
+ ```yaml
351
+ # _config.yml - collection default
352
+ collections:
353
+ posts:
354
+ permalink: /blog/:year/:slug/
355
+ ```
356
+
357
+ ```yaml
358
+ # Individual post front matter - override
359
+ ---
360
+ title: "Special Post"
361
+ permalink: /featured/special-post/
362
+ ---
363
+ ```
364
+
365
+ ---
366
+
367
+ ## Date from Filename
368
+
369
+ Sia can extract dates from filenames using this pattern:
370
+
371
+ ```
372
+ YYYY-MM-DD-slug.md
373
+ ```
374
+
375
+ ### Examples
376
+
377
+ | Filename | Extracted Date | Extracted Slug |
378
+ |----------|----------------|----------------|
379
+ | `2024-12-17-my-post.md` | December 17, 2024 | `my-post` |
380
+ | `2024-01-05-new-year.md` | January 5, 2024 | `new-year` |
381
+ | `about.md` | Current date | `about` |
382
+
383
+ ### Priority
384
+
385
+ Date resolution follows this priority:
386
+
387
+ 1. `date` in front matter (highest priority)
388
+ 2. Date extracted from filename
389
+ 3. Current date (fallback)
390
+
391
+ Slug resolution:
392
+
393
+ 1. `slug` in front matter (highest priority)
394
+ 2. Slug extracted from filename (after date prefix)
395
+ 3. Slugified filename
396
+
397
+ ---
398
+
399
+ ## Draft Content
400
+
401
+ Mark content as a draft to exclude it from production builds:
402
+
403
+ ```yaml
404
+ ---
405
+ title: "Work in Progress"
406
+ draft: true
407
+ ---
408
+ ```
409
+
410
+ ### Draft Behavior
411
+
412
+ | Environment | `draft: true` | `draft: false` (or omitted) |
413
+ |-------------|---------------|------------------------------|
414
+ | `sia dev` with `showDrafts: false` | Hidden | Visible |
415
+ | `sia dev` with `showDrafts: true` | Visible | Visible |
416
+ | `sia build` (production) | Hidden | Visible |
417
+
418
+ ### Enabling Draft Preview
419
+
420
+ In `_config.yml`:
421
+
422
+ ```yaml
423
+ server:
424
+ showDrafts: true
425
+ ```
426
+
427
+ When drafts are shown, they display with a "Draft" badge in most themes.
428
+
429
+ ---
430
+
431
+ ## Examples
432
+
433
+ ### Complete Blog Post
434
+
435
+ ```yaml
436
+ ---
437
+ title: "Building a Modern Web Application"
438
+ date: 2024-12-17
439
+ tags: [javascript, react, tutorial]
440
+ author: "John Smith"
441
+ excerpt: "A comprehensive guide to building modern web applications with React and TypeScript."
442
+ image: /images/posts/modern-web-app.jpg
443
+ description: "Learn how to build scalable, maintainable web applications using modern tools and practices."
444
+ draft: false
445
+ ---
446
+
447
+ ## Introduction
448
+
449
+ Welcome to this comprehensive guide...
450
+ ```
451
+
452
+ ### Minimal Blog Post
453
+
454
+ ```yaml
455
+ ---
456
+ title: "Quick Tip: CSS Variables"
457
+ tags: [css, tips]
458
+ ---
459
+
460
+ Here's a quick tip about CSS variables...
461
+ ```
462
+
463
+ ### Static Page
464
+
465
+ ```yaml
466
+ ---
467
+ title: "About"
468
+ description: "Learn about me and my work."
469
+ ---
470
+
471
+ ## About Me
472
+
473
+ I'm a software developer...
474
+ ```
475
+
476
+ ### Note/Tweet
477
+
478
+ ```yaml
479
+ ---
480
+ date: 2024-12-17T10:30:00
481
+ tags: [announcement]
482
+ ---
483
+
484
+ Just launched my new blog! Check it out at https://example.com :tada:
485
+ ```
486
+
487
+ ### Post with Custom Permalink
488
+
489
+ ```yaml
490
+ ---
491
+ title: "JavaScript Fundamentals"
492
+ date: 2024-12-17
493
+ tags: [javascript, fundamentals]
494
+ permalink: /learn/javascript/fundamentals/
495
+ ---
496
+
497
+ Let's learn JavaScript from the ground up...
498
+ ```
499
+
500
+ ---
501
+
502
+ ## YAML Tips
503
+
504
+ ### Strings
505
+
506
+ ```yaml
507
+ # All of these are valid
508
+ title: My Title
509
+ title: "My Title"
510
+ title: 'My Title'
511
+
512
+ # Use quotes for special characters
513
+ title: "My Title: A Subtitle"
514
+ title: "What's New?"
515
+ ```
516
+
517
+ ### Arrays
518
+
519
+ ```yaml
520
+ # Inline format
521
+ tags: [one, two, three]
522
+
523
+ # Block format
524
+ tags:
525
+ - one
526
+ - two
527
+ - three
528
+ ```
529
+
530
+ ### Multi-line Text
531
+
532
+ ```yaml
533
+ # Literal block (preserves newlines)
534
+ excerpt: |
535
+ This is a multi-line
536
+ excerpt that preserves
537
+ line breaks.
538
+
539
+ # Folded block (joins lines)
540
+ excerpt: >
541
+ This is a long description
542
+ that will be joined into
543
+ a single line.
544
+ ```
545
+
546
+ ### Dates
547
+
548
+ ```yaml
549
+ # Date only
550
+ date: 2024-12-17
551
+
552
+ # Date and time
553
+ date: 2024-12-17T14:30:00
554
+
555
+ # With timezone
556
+ date: 2024-12-17T14:30:00-05:00
557
+ ```