diff --git a/app/views/full-page-examples/announcements/index.njk b/app/views/full-page-examples/announcements/index.njk index cc66d99f7d..14b6bec13f 100644 --- a/app/views/full-page-examples/announcements/index.njk +++ b/app/views/full-page-examples/announcements/index.njk @@ -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 %} diff --git a/app/views/full-page-examples/index.njk b/app/views/full-page-examples/index.njk index 88cf4d4d81..3549658b0c 100644 --- a/app/views/full-page-examples/index.njk +++ b/app/views/full-page-examples/index.njk @@ -24,6 +24,18 @@

{{ example.name | replace("-", " ") | capitalize }}

+ {% if example.scenario %} +

+ {{ example.scenario }} +

+ {% endif %} + + {% if example.notes %} +

{{ example.notes }}

+ {% endif %} + +
+ {% endfor %} diff --git a/lib/file-helper.js b/lib/file-helper.js index 4bdba3f94c..2cb48471f9 100644 --- a/lib/file-helper.js +++ b/lib/file-helper.js @@ -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') @@ -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) } diff --git a/package-lock.json b/package-lock.json index 451c626f16..fd7cd22590 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5224,12 +5224,12 @@ "dev": true }, "front-matter": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/front-matter/-/front-matter-2.1.2.tgz", - "integrity": "sha1-91mDufL0E75ljJPf172M5AePXNs=", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/front-matter/-/front-matter-3.0.2.tgz", + "integrity": "sha512-iBGZaWyzqgsrPGsqrXZP6N4hp5FzSKDi18nfAoYpgz3qK5sAwFv/ojmn3VS60SOgLvq6CtojNqy0y6ZNz05IzQ==", "dev": true, "requires": { - "js-yaml": "^3.4.6" + "js-yaml": "^3.13.1" } }, "fs-exists-sync": { @@ -15573,6 +15573,15 @@ "object-assign": "^4.0.1" } }, + "front-matter": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/front-matter/-/front-matter-2.1.2.tgz", + "integrity": "sha1-91mDufL0E75ljJPf172M5AePXNs=", + "dev": true, + "requires": { + "js-yaml": "^3.4.6" + } + }, "fs-extra": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-3.0.1.tgz", diff --git a/package.json b/package.json index 470bbe1c7d..0c9007ab48 100644 --- a/package.json +++ b/package.json @@ -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",