` | false | An object to describe the [details of the downloadable file](#file) such as format and size |
-#### Type
+#### Object
| Name | Type | Required | Description |
| ---- | ------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------- |
@@ -60,3 +59,10 @@
| fileType | string | true | Format of the file, for example, PDF, DOC, XLS |
| fileSize | string | true | Size of the file in megabytes or kilobytes, for example, “850KB” |
| filePages | string | false | Number of pages in the file, for example, “16 pages” |
+
+#### Title
+
+| Name | Type | Required | Description |
+| ---- | ------ | -------- | --------------------------------------------------------- |
+| text | string | true | The title for the document |
+| url | string | true | The URL for the document link (either a file or web page) |
diff --git a/src/components/document-list/_macro.njk b/src/components/document-list/_macro.njk
index 40a89a04fa..12d9567161 100644
--- a/src/components/document-list/_macro.njk
+++ b/src/components/document-list/_macro.njk
@@ -15,7 +15,7 @@
>
{% if document.thumbnail.smallSrc and document.thumbnail.largeSrc %}
@@ -35,8 +35,8 @@
class="ons-document-list__item-header{{ ' ons-document-list__item-header--reverse' if document.showMetadataFirst == true }}"
>
{{ openingTag | safe }} class="ons-document-list__item-title ons-u-fs-m ons-u-mt-no ons-u-mb-xs">
- {{ document.title }}
+ {{ document.title.text }}
{%- if document.metadata and document.metadata.file -%}
{%
@@ -63,23 +63,23 @@
{% endif %}
- {%- if document.metadata.type and document.metadata.type.text -%}
+ {%- if document.metadata.object and document.metadata.object.text -%}
- {% set metadataType %}
+ {% set metadataObject %}
{{ document.metadata.type.text }}{%- if document.metadata.type.ref -%}:{% elif document.metadata.file %},{% endif %}{{ document.metadata.object.text }}{%- if document.metadata.object.ref -%}:{% elif document.metadata.file %},{% endif %}
{% endset %}
- {%- if document.metadata.type.url -%}
-
- {{ metadataType | safe }}
+ {%- if document.metadata.object.url -%}
+
+ {{ metadataObject | safe }}
{% else %}
- {{ metadataType | safe }}
+ {{ metadataObject | safe }}
{% endif %}
- {%- if document.metadata.type.ref -%}
- {{ document.metadata.type.ref }}
+ {%- if document.metadata.object.ref -%}
+ {{ document.metadata.object.ref }}
{% endif %}
{% endif %}
diff --git a/src/components/document-list/_macro.spec.js b/src/components/document-list/_macro.spec.js
index d382751cf2..2701bd07c2 100644
--- a/src/components/document-list/_macro.spec.js
+++ b/src/components/document-list/_macro.spec.js
@@ -6,8 +6,10 @@ import axe from '../../tests/helpers/axe';
import { renderComponent } from '../../tests/helpers/rendering';
const EXAMPLE_DOCUMENT_LIST_BASIC = {
- url: '#0',
- title: 'Crime and justice',
+ title: {
+ text: 'Crime and justice',
+ url: '#0',
+ },
description: 'Some description',
};
@@ -30,10 +32,10 @@ const EXAMPLE_DOCUMENT_LIST_WITH_METADATA_FILE = {
},
};
-const EXAMPLE_DOCUMENT_LIST_WITH_METADATA_TYPE = {
+const EXAMPLE_DOCUMENT_LIST_WITH_METADATA_OBJECT = {
...EXAMPLE_DOCUMENT_LIST_BASIC,
metadata: {
- type: {
+ object: {
text: 'Poster',
url: '#0',
ref: 'some ref',
@@ -49,7 +51,7 @@ const EXAMPLE_DOCUMENT_LIST_WITH_MULTIPLE = {
largeSrc: '/example-large.png',
},
metadata: {
- type: {
+ object: {
text: 'Poster',
url: '#0',
ref: 'some ref',
@@ -256,11 +258,11 @@ describe('macro: document list', () => {
});
});
- describe('mode: with metadata `type` configuration', () => {
+ describe('mode: with metadata `object` configuration', () => {
it('passes jest-axe checks', async () => {
const $ = cheerio.load(
renderComponent('document-list', {
- documents: [EXAMPLE_DOCUMENT_LIST_WITH_METADATA_TYPE],
+ documents: [EXAMPLE_DOCUMENT_LIST_WITH_METADATA_OBJECT],
}),
);
@@ -271,7 +273,7 @@ describe('macro: document list', () => {
it('has the provided `url`', () => {
const $ = cheerio.load(
renderComponent('document-list', {
- documents: [EXAMPLE_DOCUMENT_LIST_WITH_METADATA_TYPE],
+ documents: [EXAMPLE_DOCUMENT_LIST_WITH_METADATA_OBJECT],
}),
);
@@ -280,13 +282,13 @@ describe('macro: document list', () => {
});
it('has expected `text`', () => {
- const $ = cheerio.load(renderComponent('document-list', { documents: [EXAMPLE_DOCUMENT_LIST_WITH_METADATA_TYPE] }));
+ const $ = cheerio.load(renderComponent('document-list', { documents: [EXAMPLE_DOCUMENT_LIST_WITH_METADATA_OBJECT] }));
const text = $('.ons-document-list__attribute-link > span').text().trim();
expect(text).toBe('Poster:');
});
it('has expected `ref`', () => {
- const $ = cheerio.load(renderComponent('document-list', { documents: [EXAMPLE_DOCUMENT_LIST_WITH_METADATA_TYPE] }));
+ const $ = cheerio.load(renderComponent('document-list', { documents: [EXAMPLE_DOCUMENT_LIST_WITH_METADATA_OBJECT] }));
const text = $('.ons-document-list__attribute-link + span').text().trim();
expect(text).toBe('some ref');
});
diff --git a/src/components/document-list/example-document-list-article-featured.njk b/src/components/document-list/example-document-list-article-featured.njk
index d1aa536c5e..40f5e97211 100644
--- a/src/components/document-list/example-document-list-article-featured.njk
+++ b/src/components/document-list/example-document-list-article-featured.njk
@@ -14,10 +14,12 @@
"smallSrc": '/img/small/census-monuments-lights-featured.jpg',
"largeSrc": '/img/large/census-monuments-lights-featured.jpg'
},
- "url": '#0',
- "title": 'Landmarks are lighting up purple to mark Census Day',
+ "title": {
+ "text": 'Landmarks are lighting up purple to mark Census Day',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Press releases',
"url": '#0'
},
diff --git a/src/components/document-list/example-document-list-articles.njk b/src/components/document-list/example-document-list-articles.njk
index 494ad0596c..0e12376c0a 100644
--- a/src/components/document-list/example-document-list-articles.njk
+++ b/src/components/document-list/example-document-list-articles.njk
@@ -8,10 +8,12 @@
"smallSrc": '/img/small/census-monuments-lights.jpg',
"largeSrc": '/img/large/census-monuments-lights.jpg'
},
- "url": '#0',
- "title": 'Landmarks are lighting up purple to mark Census Day',
+ "title": {
+ "text": 'Landmarks are lighting up purple to mark Census Day',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Press releases',
"url": '#0'
},
@@ -27,10 +29,12 @@
"smallSrc": '/img/small/ons-award-winners.jpg',
"largeSrc": '/img/large/ons-award-winners.jpg'
},
- "url": '#0',
- "title": 'Office for National Statistics win top Royal Statistical Society award',
+ "title": {
+ "text": 'Office for National Statistics win top Royal Statistical Society award',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Press releases',
"url": '#0'
},
@@ -43,10 +47,12 @@
},
{
"thumbnail": true,
- "url": '#0',
- "title": 'Five Office for National Statistics names in New Year’s Honours',
+ "title": {
+ "text": 'Five Office for National Statistics names in New Year’s Honours',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Press releases',
"url": '#0'
},
diff --git a/src/components/document-list/example-document-list-downloads.njk b/src/components/document-list/example-document-list-downloads.njk
index 2b8201e5fe..1e34719579 100644
--- a/src/components/document-list/example-document-list-downloads.njk
+++ b/src/components/document-list/example-document-list-downloads.njk
@@ -4,10 +4,12 @@
"documents": [
{
"thumbnail": true,
- "url": '#',
- "title": 'Including everyone in Census 2021',
+ "title": {
+ "text": 'Including everyone in Census 2021',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Poster'
},
"file": {
@@ -20,10 +22,12 @@
},
{
"thumbnail": true,
- "url": '#',
- "title": 'Community handbook for Census 2021',
+ "title": {
+ "text": 'Community handbook for Census 2021',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Booklet'
},
"file": {
@@ -36,10 +40,12 @@
},
{
"thumbnail": true,
- "url": '#',
- "title": 'Census 2021 matters to everyone',
+ "title": {
+ "text": 'Census 2021 matters to everyone',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Poster'
},
"file": {
diff --git a/src/components/document-list/example-document-list-search-result-featured.njk b/src/components/document-list/example-document-list-search-result-featured.njk
index 41016a8167..c48ca5fc27 100644
--- a/src/components/document-list/example-document-list-search-result-featured.njk
+++ b/src/components/document-list/example-document-list-search-result-featured.njk
@@ -6,10 +6,12 @@
{
"featured": true,
"showMetadataFirst": true,
- "url": '#0',
- "title": 'Crime and justice',
+ "title": {
+ "text": 'Crime and justice',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Topic'
}
},
diff --git a/src/components/document-list/example-document-list-search-results.njk b/src/components/document-list/example-document-list-search-results.njk
index 9b97873b0a..258a410832 100644
--- a/src/components/document-list/example-document-list-search-results.njk
+++ b/src/components/document-list/example-document-list-search-results.njk
@@ -6,10 +6,12 @@
{
"featured": true,
"showMetadataFirst": true,
- "url": '#0',
- "title": 'Crime and justice',
+ "title": {
+ "text": 'Crime and justice',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Topic'
}
},
@@ -17,10 +19,12 @@
View all datasets or publications related to Crime and justice
'
},
{
- "url": '#0',
- "title": 'Disability and crime',
+ "title": {
+ "text": 'Disability and crime',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Dataset'
},
"date": {
@@ -33,10 +37,12 @@
"description": 'Domestic abuse and sexual assault outcomes for disabled people in England and Wales aged 16 to 59 years, with analysis by age, sex, impairment type, impairment severity, country and region using the Crime Survey for England and Wales (CSEW) data.
'
},
{
- "url": '#0',
- "title": 'Disability and crime, UK: 2019 (Latest release)',
+ "title": {
+ "text": 'Disability and crime, UK: 2019 (Latest release)',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Statistical bulletin'
},
"date": {
@@ -49,10 +55,12 @@
"description": 'An overview of published data on disability and crime in the UK and analysis of the experience of domestic abuse and sexual assault for disabled adults aged 16 to 59 years in England and Wales. Analysis by age, sex and impairment type.
'
},
{
- "url": '#0',
- "title": 'Hate crime by disability status, Crime Survey for England and Wales (CSEW) combined years 2013 and 2014 to 2015 and 2016',
+ "title": {
+ "text": 'Hate crime by disability status, Crime Survey for England and Wales (CSEW) combined years 2013 and 2014 to 2015 and 2016',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'User requested data',
"ref": 'Ref 008052'
},
diff --git a/src/components/download-resources/download-resources.spec.js b/src/components/download-resources/download-resources.spec.js
index fd88dd196b..c01d0c8ed3 100644
--- a/src/components/download-resources/download-resources.spec.js
+++ b/src/components/download-resources/download-resources.spec.js
@@ -147,8 +147,10 @@ const EXAMPLE_PAGE = `
'data-filter': 'general-public booklet',
'data-sort-index': '1',
},
- url: '/example-booklet-1',
- title: 'Example booklet 1',
+ title: {
+ url: '/example-booklet-1',
+ text: 'Example booklet 1',
+ },
description: 'The first example booklet.',
},
{
@@ -157,8 +159,10 @@ const EXAMPLE_PAGE = `
'data-filter': 'general-public booklet logo',
'data-sort-index': '2',
},
- url: '/example-booklet-2',
- title: 'Example booklet 2 with logo',
+ title: {
+ url: '/example-booklet-2',
+ text: 'Example booklet 2 with logo',
+ },
description: 'The second example booklet with a logo.',
},
{
@@ -167,8 +171,10 @@ const EXAMPLE_PAGE = `
'data-filter': 'logo',
'data-sort-index': '3',
},
- url: '/example-logo',
- title: 'Example logo',
+ title: {
+ url: '/example-logo',
+ text: 'Example logo',
+ },
description: 'An example logo.',
},
],
diff --git a/src/patterns/download-resources/example-download-resources.njk b/src/patterns/download-resources/example-download-resources.njk
index 98d88a7d2f..9e874fcd12 100644
--- a/src/patterns/download-resources/example-download-resources.njk
+++ b/src/patterns/download-resources/example-download-resources.njk
@@ -312,10 +312,12 @@ layout: ~
"data-sort-index": '1'
},
"thumbnail": true,
- "url": '#',
- "title": "Census 2021 matters to everyone",
+ "title": {
+ "text": 'Census 2021 matters to everyone',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Poster'
},
"file": {
@@ -333,10 +335,12 @@ layout: ~
"data-sort-index": '2'
},
"thumbnail": true,
- "url": '#',
- "title": 'Including everyone in Census 2021',
+ "title": {
+ "text": 'Including everyone in Census 2021',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Poster'
},
"file": {
@@ -354,10 +358,12 @@ layout: ~
"data-sort-index": '3'
},
"thumbnail": true,
- "url": '#',
- "title": "Census awareness poster",
+ "title": {
+ "text": 'Census awareness poster',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Poster'
},
"file": {
@@ -375,10 +381,12 @@ layout: ~
"data-sort-index": '4'
},
"thumbnail": true,
- "url": '#',
- "title": "Community handbook for Census 2021",
+ "title": {
+ "text": 'Community handbook for Census 2021',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Booklet'
},
"file": {
@@ -396,10 +404,12 @@ layout: ~
"data-sort-index": '5'
},
"thumbnail": true,
- "url": '#',
- "title": "Brand guidelines for Census 2021",
+ "title": {
+ "text": 'Brand guidelines for Census 2021',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": "Booklet"
},
"file": {
@@ -417,10 +427,12 @@ layout: ~
"data-sort-index": '6'
},
"thumbnail": true,
- "url": '#',
- "title": "Tone of voice for Census 2021",
+ "title": {
+ "text": 'Tone of voice for Census 2021',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": "Booklet"
},
"file": {
@@ -438,10 +450,12 @@ layout: ~
"data-sort-index": '7'
},
"thumbnail": true,
- "url": "#0",
- "title": "Default awareness pop-up stand graphics for Census 2021",
+ "title": {
+ "text": 'Default awareness pop-up stand graphics for Census 2021',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": "Poster"
},
"file": {
@@ -459,10 +473,12 @@ layout: ~
"data-sort-index": '8'
},
"thumbnail": true,
- "url": "#0",
- "title": "Field officer jobs poster for Census 2021",
+ "title": {
+ "text": 'Field officer jobs poster for Census 2021',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": "Poster"
},
"file": {
@@ -480,10 +496,12 @@ layout: ~
"data-sort-index": '9'
},
"thumbnail": true,
- "url": "#0",
- "title": "Census 2021 logos pack for print and web",
+ "title": {
+ "text": 'Census 2021 logos pack for print and web',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": "Logo"
},
"file": {
diff --git a/src/patterns/news/example-category.njk b/src/patterns/news/example-category.njk
index 3f2f4d1ff5..3cf4d2ca1e 100644
--- a/src/patterns/news/example-category.njk
+++ b/src/patterns/news/example-category.njk
@@ -47,10 +47,12 @@ layout: ~
"smallSrc": '/img/small/ons-award-winners.jpg',
"largeSrc": '/img/large/ons-award-winners.jpg'
},
- "url": '#0',
- "title": 'Office for National Statistics win top Royal Statistical Society award',
+ "title": {
+ "text": 'Office for National Statistics win top Royal Statistical Society award',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Press releases',
"url": '#0'
},
@@ -66,10 +68,12 @@ layout: ~
"smallSrc": '/img/small/alison-pritchard.jpg',
"largeSrc": '/img/large/alison-pritchard.jpg'
},
- "url": '#0',
- "title": 'ONS launches Integrated Data Service to boost government collaboration on data sharing',
+ "title": {
+ "text": 'ONS launches Integrated Data Service to boost government collaboration on data sharing',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Press releases',
"url": '#0'
},
@@ -82,10 +86,12 @@ layout: ~
},
{
"thumbnail": true,
- "url": '#0',
- "title": 'Five Office for National Statistics names in New Year’s Honours',
+ "title": {
+ "text": 'Five Office for National Statistics names in New Year’s Honours',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Press releases',
"url": '#0'
},
@@ -98,10 +104,12 @@ layout: ~
},
{
"thumbnail": true,
- "url": '#0',
- "title": 'National Data Strategy – the ONS takes centre stage',
+ "title": {
+ "text": 'National Data Strategy – the ONS takes centre stage',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Press releases',
"url": '#0'
},
@@ -114,10 +122,12 @@ layout: ~
},
{
"thumbnail": true,
- "url": '#0',
- "title": 'The ONS named among the UK’s best employers for working families',
+ "title": {
+ "text": 'The ONS named among the UK’s best employers for working families',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Press releases',
"url": '#0'
},
diff --git a/src/patterns/news/example-landing.njk b/src/patterns/news/example-landing.njk
index f9b7d81049..3129386647 100644
--- a/src/patterns/news/example-landing.njk
+++ b/src/patterns/news/example-landing.njk
@@ -45,10 +45,12 @@ layout: ~
"smallSrc": '/img/small/census-monuments-lights-featured.jpg',
"largeSrc": '/img/large/census-monuments-lights-featured.jpg'
},
- "url": '#0',
- "title": 'Landmarks are lighting up purple to mark Census Day',
+ "title": {
+ "text": 'Landmarks are lighting up purple to mark Census Day',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Press releases',
"url": '#0'
},
@@ -74,10 +76,12 @@ layout: ~
"smallSrc": '/img/small/ons-award-winners.jpg',
"largeSrc": '/img/large/ons-award-winners.jpg'
},
- "url": '#0',
- "title": 'Office for National Statistics win top Royal Statistical Society award',
+ "title": {
+ "text": 'Office for National Statistics win top Royal Statistical Society award',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Press releases',
"url": '#0'
},
@@ -93,10 +97,12 @@ layout: ~
"smallSrc": '/img/small/alison-pritchard.jpg',
"largeSrc": '/img/large/alison-pritchard.jpg'
},
- "url": '#0',
- "title": 'ONS launches Integrated Data Service to boost government collaboration on data sharing',
+ "title": {
+ "text": 'ONS launches Integrated Data Service to boost government collaboration on data sharing',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Press releases',
"url": '#0'
},
@@ -109,10 +115,12 @@ layout: ~
},
{
"thumbnail": true,
- "url": '#0',
- "title": 'Five Office for National Statistics names in New Year’s Honours',
+ "title": {
+ "text": 'Five Office for National Statistics names in New Year’s Honours',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Press releases',
"url": '#0'
},
@@ -125,10 +133,12 @@ layout: ~
},
{
"thumbnail": true,
- "url": '#0',
- "title": 'National Data Strategy – the ONS takes centre stage',
+ "title": {
+ "text": 'National Data Strategy – the ONS takes centre stage',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Press releases',
"url": '#0'
},
@@ -141,10 +151,12 @@ layout: ~
},
{
"thumbnail": true,
- "url": '#0',
- "title": 'The ONS named among the UK’s best employers for working families',
+ "title": {
+ "text": 'The ONS named among the UK’s best employers for working families',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Press releases',
"url": '#0'
},
diff --git a/src/patterns/news/example-tag.njk b/src/patterns/news/example-tag.njk
index 179c7b1ca3..10b45c3096 100644
--- a/src/patterns/news/example-tag.njk
+++ b/src/patterns/news/example-tag.njk
@@ -46,10 +46,12 @@ layout: ~
"smallSrc": '/img/small/alison-pritchard.jpg',
"largeSrc": '/img/large/alison-pritchard.jpg'
},
- "url": '#0',
- "title": 'ONS launches Integrated Data Service to boost government collaboration on data sharing',
+ "title": {
+ "text": 'ONS launches Integrated Data Service to boost government collaboration on data sharing',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Press releases',
"url": '#0'
},
@@ -62,10 +64,12 @@ layout: ~
},
{
"thumbnail": true,
- "url": '#0',
- "title": 'Integrated Data Service',
+ "title": {
+ "text": 'Integrated Data Service',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Press releases',
"url": '#0'
},
@@ -78,10 +82,12 @@ layout: ~
},
{
"thumbnail": true,
- "url": '#0',
- "title": 'Integrated Data for Population Statistics Conference 2018',
+ "title": {
+ "text": 'Integrated Data for Population Statistics Conference 2018',
+ "url": '#0'
+ },
"metadata": {
- "type": {
+ "object": {
"text": 'Press releases',
"url": '#0'
},