forked from jekyll/jekyll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollections_dir.feature
435 lines (404 loc) · 18.5 KB
/
collections_dir.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
Feature: Collections Directory
As a hacker who likes to structure content without clutter
I want to be able to organize my collections under a single directory
And render them from there
Scenario: Custom collections_dir containing only posts
And I have a collections/_posts directory
And I have the following post within the "collections" directory:
| title | date | content |
| Gathered Post | 2009-03-27 | Random Content. |
And I have a "_config.yml" file with content:
"""
collections_dir: collections
"""
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see "Random Content." in "_site/2009/03/27/gathered-post.html"
Scenario: Rendered collection in custom collections_dir also containing posts
Given I have a collections/_puppies directory
And I have the following document under the "puppies" collection within the "collections" directory:
| title | date | content |
| Rover | 2007-12-31 | content for Rover. |
And I have a collections/_posts directory
And I have the following post within the "collections" directory:
| title | date | content |
| Gathered Post | 2009-03-27 | Random Content. |
And I have a "_config.yml" file with content:
"""
collections:
puppies:
output: true
collections_dir: collections
"""
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And the "_site/puppies/rover.html" file should exist
And I should see "Random Content." in "_site/2009/03/27/gathered-post.html"
Scenario: Rendered collection in custom collections_dir with posts at the site root
Given I have a collections/_puppies directory
And I have the following document under the "puppies" collection within the "collections" directory:
| title | date | content |
| Rover | 2007-12-31 | content for Rover. |
And I have a _posts directory
And I have the following post:
| title | date | content |
| Post At Root | 2009-03-27 | Random Content. |
And I have a "_config.yml" file with content:
"""
collections:
puppies:
output: true
collections_dir: collections
"""
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And the "_site/puppies/rover.html" file should exist
And the "_site/2009/03/27/post-at-root.html" file should not exist
And the _site/_posts directory should not exist
Scenario: Rendered collection in custom collections_dir also containing drafts
Given I have a collections/_puppies directory
And I have the following document under the "puppies" collection within the "collections" directory:
| title | date | content |
| Rover | 2007-12-31 | content for Rover. |
And I have a collections/_drafts directory
And I have the following draft within the "collections" directory:
| title | date | content |
| Gathered Draft | 2009-03-27 | Random Content. |
And I have a "_config.yml" file with content:
"""
collections:
puppies:
output: true
collections_dir: collections
"""
When I run jekyll build --drafts
Then I should get a zero exit status
And the _site directory should exist
And the "_site/puppies/rover.html" file should exist
And I should see "Random Content." in "_site/2009/03/27/gathered-draft.html"
And the _site/collections directory should not exist
Scenario: Rendered collection in custom collections_dir with drafts at the site root
Given I have a collections/_puppies directory
And I have the following document under the "puppies" collection within the "collections" directory:
| title | date | content |
| Rover | 2007-12-31 | content for Rover. |
And I have a _drafts directory
And I have the following draft:
| title | date | content |
| Draft At Root | 2009-03-27 | Random Content. |
And I have a "_config.yml" file with content:
"""
collections:
puppies:
output: true
collections_dir: collections
"""
When I run jekyll build --drafts
Then I should get a zero exit status
And the _site directory should exist
And the "_site/puppies/rover.html" file should exist
And the "_site/2009/03/27/draft-at-root.html" file should not exist
Scenario: A complex site with collections posts and drafts at various locations
Given I have a gathering/_puppies directory
And I have a gathering/_posts directory
And I have a gathering/_drafts directory
And I have a _puppies directory
And I have a _posts directory
And I have a _drafts directory
And I have the following document under the "puppies" collection within the "gathering" directory:
| title | date | content |
| Rover in Gathering | 2007-12-31 | content for Rover. |
And I have the following document under the puppies collection:
| title | date | content |
| Rover At Root | 2007-12-31 | content for Rover. |
And I have the following post within the "gathering" directory:
| title | date | content |
| Post in Gathering | 2009-03-27 | Totally nothing. |
And I have the following post:
| title | date | content |
| Post At Root | 2009-03-27 | Totally nothing. |
And I have the following draft within the "gathering" directory:
| title | date | content |
| Draft In Gathering | 2009-03-27 | This is a draft. |
And I have the following draft:
| title | date | content |
| Draft At Root | 2009-03-27 | This is a draft. |
And I have a "_config.yml" file with content:
"""
collections:
puppies:
output: true
collections_dir: gathering
"""
And I have a "gathering/_puppies/static_file.txt" file that contains "Static content."
And I have a gathering/_puppies/nested directory
And I have a "gathering/_puppies/nested/static_file.txt" file that contains "Nested Static content."
When I run jekyll build --drafts
Then I should get a zero exit status
And the _site directory should exist
And the "_site/puppies/rover-in-gathering.html" file should exist
And the "_site/2009/03/27/post-in-gathering.html" file should exist
And the "_site/2009/03/27/draft-in-gathering.html" file should exist
And the "_site/2009/03/27/draft-at-root.html" file should not exist
And the "_site/puppies/rover-at-root.html" file should not exist
And I should see exactly "Static content." in "_site/puppies/static_file.txt"
And I should see exactly "Nested Static content." in "_site/puppies/nested/static_file.txt"
And the _site/gathering directory should not exist
And the _site/_posts directory should not exist
Scenario: Rendered collection with a document that includes a relative document
Given I have a _puppies directory
And I have the following documents under the puppies collection:
| title | date | content |
| INTRO | 2007-12-31 | excerpt for all docs. |
| Rover | 2007-12-31 | {% include_relative intro.md %} |
And I have a _posts directory
And I have the following post:
| title | date | content |
| Gathered Post | 2009-03-27 | Random Content. |
And I have a "_config.yml" file with content:
"""
collections:
puppies:
output: true
"""
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And the "_site/puppies/rover.html" file should exist
And I should see "excerpt for all docs." in "_site/puppies/rover.html"
And I should see "Random Content." in "_site/2009/03/27/gathered-post.html"
Scenario: Rendered collection in custom collections_dir with a document that includes a relative document
Given I have a collections/_puppies directory
And I have the following documents under the "puppies" collection within the "collections" directory:
| title | date | content |
| INTRO | 2007-12-31 | excerpt for all docs. |
| Rover | 2007-12-31 | {% include_relative intro.md %} |
And I have a collections/_posts directory
And I have the following post within the "collections" directory:
| title | date | content |
| Gathered Post | 2009-03-27 | Random Content. |
And I have a "_config.yml" file with content:
"""
collections:
puppies:
output: true
collections_dir: collections
"""
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And the "_site/puppies/rover.html" file should exist
And I should see "excerpt for all docs." in "_site/puppies/rover.html"
And I should see "Random Content." in "_site/2009/03/27/gathered-post.html"
Scenario: Front matter defaults and custom collections directory
Given I have a gathering/_players/managers directory
And I have a gathering/_players/recruits directory
And I have a gathering/_players/standby directory
And I have the following documents nested inside "managers" directory under the "players" collection within the "gathering" directory:
| title | content |
| Tony Stark | content for Tony. |
| Steve Rogers | content for Steve. |
And I have the following documents nested inside "recruits" directory under the "players" collection within the "gathering" directory:
| title | content |
| Peter Parker | content for Peter. |
| Wanda Maximoff | content for Wanda. |
And I have the following documents nested inside "standby" directory under the "players" collection within the "gathering" directory:
| title | content |
| Thanos | content for Thanos. |
| Loki | content for Loki. |
And I have a "_config.yml" file with content:
"""
collections_dir: gathering
collections: ["players"]
defaults:
- scope:
path: ""
type: players
values:
recruit: false
manager: false
villain: false
- scope:
path: gathering/_players/standby/thanos.md
type: players
values:
villain: true
- scope:
path: gathering/_players/managers/*
type: players
values:
manager: true
- scope:
path: gathering/_players/recruits/*
type: players
values:
recruit: true
"""
And I have a "index.md" file with content:
"""
---
---
{% for player in site.players %}
<p>{{ player.title }}: Manager: {{ player.manager }}</p>
<p>{{ player.title }}: Recruit: {{ player.recruit }}</p>
<p>{{ player.title }}: Villain: {{ player.villain }}</p>
{% endfor %}
"""
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see "<p>Tony Stark: Manager: true</p>" in "_site/index.html"
And I should see "<p>Tony Stark: Recruit: false</p>" in "_site/index.html"
And I should see "<p>Tony Stark: Villain: false</p>" in "_site/index.html"
And I should see "<p>Peter Parker: Manager: false</p>" in "_site/index.html"
And I should see "<p>Peter Parker: Recruit: true</p>" in "_site/index.html"
And I should see "<p>Peter Parker: Villain: false</p>" in "_site/index.html"
And I should see "<p>Steve Rogers: Manager: true</p>" in "_site/index.html"
And I should see "<p>Steve Rogers: Recruit: false</p>" in "_site/index.html"
And I should see "<p>Steve Rogers: Villain: false</p>" in "_site/index.html"
And I should see "<p>Wanda Maximoff: Manager: false</p>" in "_site/index.html"
And I should see "<p>Wanda Maximoff: Recruit: true</p>" in "_site/index.html"
And I should see "<p>Wanda Maximoff: Villain: false</p>" in "_site/index.html"
And I should see "<p>Thanos: Manager: false</p>" in "_site/index.html"
And I should see "<p>Thanos: Recruit: false</p>" in "_site/index.html"
And I should see "<p>Thanos: Villain: true</p>" in "_site/index.html"
And I should see "<p>Loki: Manager: false</p>" in "_site/index.html"
And I should see "<p>Loki: Recruit: false</p>" in "_site/index.html"
And I should see "<p>Loki: Villain: false</p>" in "_site/index.html"
Scenario: Sort all entries by a Front Matter key defined in all entries
Given I have an "index.html" page that contains "Collections: {{ site.tutorials | map: 'title' | join: ', ' }}"
And I have fixture collections in "gathering" directory
And I have a _layouts directory
And I have a "_layouts/tutorial.html" file with content:
"""
{% if page.previous %}Previous: {{ page.previous.title }}{% endif %}
{% if page.next %}Next: {{ page.next.title }}{% endif %}
"""
And I have a "_config.yml" file with content:
"""
collections_dir: gathering
collections:
tutorials:
output: true
sort_by: lesson
defaults:
- scope:
path: ""
type: tutorials
values:
layout: tutorial
"""
When I run jekyll build
Then I should get a zero exit status
Then the _site directory should exist
And I should see "Collections: Getting Started, Let's Roll!, Dive-In and Publish Already!, Tip of the Iceberg, Extending with Plugins, Graduation Day" in "_site/index.html"
And I should not see "Previous: Graduation Day" in "_site/tutorials/lets-roll.html"
And I should not see "Next: Tip of the Iceberg" in "_site/tutorials/lets-roll.html"
But I should see "Previous: Getting Started" in "_site/tutorials/lets-roll.html"
And I should see "Next: Dive-In and Publish Already!" in "_site/tutorials/lets-roll.html"
Scenario: Sort all entries by a Front Matter key defined in only some entries
Given I have an "index.html" page that contains "Collections: {{ site.tutorials | map: 'title' | join: ', ' }}"
And I have fixture collections in "gathering" directory
And I have a _layouts directory
And I have a "_layouts/tutorial.html" file with content:
"""
{% if page.previous %}Previous: {{ page.previous.title }}{% endif %}
{% if page.next %}Next: {{ page.next.title }}{% endif %}
"""
And I have a "_config.yml" file with content:
"""
collections_dir: gathering
collections:
tutorials:
output: true
sort_by: approx_time
defaults:
- scope:
path: ""
type: tutorials
values:
layout: tutorial
"""
When I run jekyll build
Then I should get a zero exit status
Then the _site directory should exist
And I should see "'approx_time' not defined" in the build output
And I should see "Collections: Extending with Plugins, Let's Roll!, Getting Started, Graduation Day, Dive-In and Publish Already!, Tip of the Iceberg" in "_site/index.html"
And I should see "Previous: Getting Started" in "_site/tutorials/graduation-day.html"
And I should see "Next: Dive-In and Publish Already!" in "_site/tutorials/graduation-day.html"
Scenario: Manually sort entries
Given I have an "index.html" page that contains "Collections: {{ site.tutorials | map: 'title' | join: ', ' }}"
And I have fixture collections in "gathering" directory
And I have a _layouts directory
And I have a "_layouts/tutorial.html" file with content:
"""
{% if page.previous %}Previous: {{ page.previous.title }}{% endif %}
{% if page.next %}Next: {{ page.next.title }}{% endif %}
"""
And I have a "_config.yml" file with content:
"""
collections_dir: gathering
collections:
tutorials:
output: true
order:
- getting-started.md
- tip-of-the-iceberg.md
- lets-roll.md
- dive-in-and-publish-already.md
- graduation-day.md
- random-plugins.md
defaults:
- scope:
path: ""
type: tutorials
values:
layout: tutorial
"""
When I run jekyll build
Then I should get a zero exit status
Then the _site directory should exist
And I should see "Collections: Getting Started, Tip of the Iceberg, Let's Roll!, Dive-In and Publish Already!, Graduation Day, Extending with Plugins" in "_site/index.html"
And I should not see "Previous: Graduation Day" in "_site/tutorials/lets-roll.html"
And I should not see "Next: Tip of the Iceberg" in "_site/tutorials/lets-roll.html"
But I should see "Previous: Tip of the Iceberg" in "_site/tutorials/lets-roll.html"
And I should see "Next: Dive-In and Publish Already!" in "_site/tutorials/lets-roll.html"
Scenario: Manually sort some entries
Given I have an "index.html" page that contains "Collections: {{ site.tutorials | map: 'title' | join: ', ' }}"
And I have fixture collections in "gathering" directory
And I have a _layouts directory
And I have a "_layouts/tutorial.html" file with content:
"""
{% if page.previous %}Previous: {{ page.previous.title }}{% endif %}
{% if page.next %}Next: {{ page.next.title }}{% endif %}
"""
And I have a "_config.yml" file with content:
"""
collections_dir: gathering
collections:
tutorials:
output: true
order:
- getting-started.md
- lets-roll.md
- dive-in-and-publish-already.md
- graduation-day.md
defaults:
- scope:
path: ""
type: tutorials
values:
layout: tutorial
"""
When I run jekyll build
Then I should get a zero exit status
Then the _site directory should exist
And I should see "Collections: Getting Started, Let's Roll!, Dive-In and Publish Already!, Graduation Day, Extending with Plugins, Tip of the Iceberg" in "_site/index.html"
And I should not see "Previous: Graduation Day" in "_site/tutorials/lets-roll.html"
And I should not see "Previous: Tip of the Iceberg" in "_site/tutorials/lets-roll.html"
And I should not see "Next: Tip of the Iceberg" in "_site/tutorials/lets-roll.html"
But I should see "Previous: Getting Started" in "_site/tutorials/lets-roll.html"
And I should see "Next: Dive-In and Publish Already!" in "_site/tutorials/lets-roll.html"