Skip to content

Commit

Permalink
Read scenario and notes from front-matter
Browse files Browse the repository at this point in the history
  • Loading branch information
36degrees authored and aliuk2012 committed Jun 14, 2019
1 parent 27b693d commit df8634c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
5 changes: 4 additions & 1 deletion app/views/full-page-examples/announcements/index.njk
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{# This example is based on the "2018’s oddest requests from Brits abroad: ‘Strictly’, vampires and sausages" publication: https://www.gov.uk/government/news/strictly-vampires-and-sausages-2018s-oddest-requests-from-brits-abroad #}
---
scenario: You want to read this article about '2018’s oddest requests from Brits abroad'.
notes: Based on https://www.gov.uk/government/news/strictly-vampires-and-sausages-2018s-oddest-requests-from-brits-abroad
---
{% extends "_generic.njk" %}

{% from "breadcrumbs/macro.njk" import govukBreadcrumbs %}
Expand Down
12 changes: 12 additions & 0 deletions app/views/full-page-examples/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@

<h2 class="govuk-heading-m"><a href="/full-page-examples/{{ example.path }}" class="govuk-link">{{ example.name | replace("-", " ") | capitalize }}</a></h2>

{% if example.scenario %}
<p class="govuk-body">
{{ example.scenario }}
</p>
{% endif %}

{% if example.notes %}
<p class="govuk-body govuk-!-font-size-16">{{ example.notes }}</p>
{% endif %}

<hr class="govuk-section-break govuk-section-break--l" />

{% endfor %}
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion lib/file-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const fs = require('fs')
const path = require('path')
const yaml = require('js-yaml')
const fm = require('front-matter')

const configPaths = require('../config/paths.json')

Expand Down Expand Up @@ -39,7 +40,8 @@ exports.fullPageExamples = () => {
return childDirectories(path.resolve(configPaths.fullPageExamples))
.map(folderName => ({
name: folderName,
path: folderName
path: folderName,
...fm(readFileContents(path.join(configPaths.fullPageExamples, folderName, 'index.njk'))).attributes
}))
.sort((a, b) => (a.name > b.name) ? 1 : -1)
}
17 changes: 13 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"eslint": "^5.16.0",
"express": "^4.16.4",
"express-validator": "^5.3.1",
"front-matter": "^3.0.2",
"glob": "^7.1.3",
"govuk-elements-sass": "3.1.3",
"govuk_frontend_toolkit": "8.1.0",
Expand Down

0 comments on commit df8634c

Please sign in to comment.