@x-govuk/govuk-eleventy-plugin
Version:
Write documentation using Markdown and publish it using GOV.UK styles
16 lines (14 loc) • 389 B
JavaScript
import { smart } from './smart.js'
/**
* Transform list of posts in a collection to `items` array that can be
* consumed by GOV.UK Frontend components
*
* @param {Array} array - Eleventy collection data
* @returns {Array} `items` array
*/
export function itemsFromCollection(array) {
return array.map((item) => ({
text: smart(item.data.title),
href: item.data.url
}))
}