Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Eleventy’s HTML base plugin
Browse files Browse the repository at this point in the history
paulrobertlloyd committed Dec 12, 2023

Verified

This commit was signed with the committer’s verified signature. The key has expired.
paulrobertlloyd Paul Robert Lloyd
1 parent e76fc72 commit c266969
Showing 12 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion components/document-list/template.njk
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
{% for item in params.items %}
<li class="app-document-list__item">
<h{{ headingLevel }} class="app-document-list__item-title">
<a class="govuk-link" href="{{ item.url | url | pretty }}">{{ item.data.title | smart }}</a>
<a class="govuk-link" href="{{ item.url | pretty }}">{{ item.data.title | smart }}</a>
</h{{ headingLevel }}>
{% if item.data.description %}
<p class="app-document-list__item-description">
2 changes: 1 addition & 1 deletion components/header/template.njk
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
<header class="govuk-header app-header" role="banner" data-module="govuk-header">
<div class="govuk-header__container govuk-width-container app-header__container">
<div class="govuk-header__logo app-header__logo">
<a href="{{ params.homepageUrl | default("/") | url }}" class="govuk-header__link govuk-header__link--homepage">
<a href="{{ params.homepageUrl | default("/") }}" class="govuk-header__link govuk-header__link--homepage">
{% if params.logotype == "x-govuk" %}
{% include "./_x-govuk.svg" %}
{% elif params.logotype.html %}
4 changes: 2 additions & 2 deletions components/site-search/template.njk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="app-site-search govuk-!-display-none-print" data-module="app-site-search" data-search-index="{{ params.indexPath | url }}">
<div class="app-site-search govuk-!-display-none-print" data-module="app-site-search" data-search-index="{{ params.indexPath }}">
<label class="govuk-visually-hidden" for="app-site-search__input">{{ params.label | default("Search site") }}</label>
<a class="app-site-search__link govuk-link-no-visited" href="{{ params.sitemapPath | url }}">Sitemap</a>
<a class="app-site-search__link govuk-link-no-visited" href="{{ params.sitemapPath }}">Sitemap</a>
</div>
2 changes: 1 addition & 1 deletion docs/404.md
Original file line number Diff line number Diff line change
@@ -7,4 +7,4 @@ permalink: 404.html

If you entered a web address please check it was correct.

You can browse from [the homepage]({{ "/" | url }}) or use the [sitemap]({{ "/sitemap" | url }}) to find the information you need.
You can browse from [the homepage](/) or use the [sitemap](/sitemap) to find the information you need.
2 changes: 1 addition & 1 deletion docs/get-started.md
Original file line number Diff line number Diff line change
@@ -111,6 +111,6 @@ This plugin provides {{ collections.layout | length }} different layouts, each w
{% for page in collections.layout %}
- [{{ page.data.title }}]({{ page.url | url }}) – {{ page.data.description }}
- [{{ page.data.title }}]({{ page.url }}) – {{ page.data.description }}
{% endfor %}
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ eleventyComputed:
<section class="govuk-grid-column-one-third-from-desktop govuk-!-margin-bottom-8">
<h2 class="govuk-heading-m govuk-!-font-size-27">{{ item.data.title | smart }}</h2>
<p class="govuk-body">{{ item.data.description | markdown("inline") }}</p>
<p class="govuk-body"><a class="govuk-link govuk-!-font-weight-bold" href="{{ item.url | url }}">Learn about {{ item.data.title | smart | lower }}</a></p>
<p class="govuk-body"><a class="govuk-link govuk-!-font-weight-bold" href="{{ item.url }}">Learn about {{ item.data.title | smart | lower }}</a></p>
</section>
{% endfor %}
<section class="govuk-grid-column-full">
2 changes: 1 addition & 1 deletion docs/layouts.md
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ description: The plugin offers a number of layouts to match the type of content

{% for page in collections.layout %}

- [{{ page.data.title }}]({{ page.url | url }}) – {{ page.data.description }}
- [{{ page.data.title }}]({{ page.url }}) – {{ page.data.description }}

{% endfor %}

3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { EleventyHtmlBasePlugin } = require("@11ty/eleventy")

module.exports = function (eleventyConfig, pluginOptions = {}) {
const { pathPrefix } = eleventyConfig

@@ -39,6 +41,7 @@ module.exports = function (eleventyConfig, pluginOptions = {}) {
})

// Plugins
eleventyConfig.addPlugin(EleventyHtmlBasePlugin)
eleventyConfig.addPlugin(require('@11ty/eleventy-navigation'))
eleventyConfig.addPlugin(require('@11ty/eleventy-plugin-rss'))

18 changes: 9 additions & 9 deletions layouts/base.njk
Original file line number Diff line number Diff line change
@@ -34,23 +34,23 @@
{% from "components/prose-scope/macro.njk" import appProseScope %}

{% block headIcons %}
<link rel="shortcut icon" sizes="16x16 32x32 48x48" href="{{ options.icons.shortcut | url }}" type="image/x-icon">
<link rel="mask-icon" href="{{ options.icons.mask | url }}" color="{{ themeColor }}">
<link rel="apple-touch-icon" href="{{ options.icons.touch | url }}">
<link rel="shortcut icon" sizes="16x16 32x32 48x48" href="{{ options.icons.shortcut }}" type="image/x-icon">
<link rel="mask-icon" href="{{ options.icons.mask }}" color="{{ themeColor }}">
<link rel="apple-touch-icon" href="{{ options.icons.touch }}">
{% endblock %}

{% block head %}
<link rel="stylesheet" href="{{ '/assets/govuk.css' | url | absoluteUrl(options.url) }}">
<link rel="stylesheet" href="{{ '/assets/govuk.css' | absoluteUrl(options.url) }}">
{% for stylesheet in options.stylesheets %}
<link rel="stylesheet" href="{{ stylesheet | url | absoluteUrl(options.url) }}">
<link rel="stylesheet" href="{{ stylesheet | absoluteUrl(options.url) }}">
{% endfor %}

<meta property="og:url" content="{{ page.url | url | absoluteUrl(options.url) }}">
<meta property="og:url" content="{{ page.url | absoluteUrl(options.url) }}">
<meta property="og:title" content="{{ title }}">
{% if description %}<meta property="og:description" name="description" content="{{ description | markdown("inline") | striptags(true) }}">{% endif %}
{% if opengraphImage %}<meta name="twitter:card" content="summary_large_image">{% endif %}
{% if opengraphImage.src %}<meta name="twitter:image" content="{{ opengraphImage.src | url | absoluteUrl(options.url) }}">
<meta property="og:image" content="{{ opengraphImage.src | url | absoluteUrl(options.url) }}">{% endif %}
{% if opengraphImage.src %}<meta name="twitter:image" content="{{ opengraphImage.src | absoluteUrl(options.url) }}">
<meta property="og:image" content="{{ opengraphImage.src | absoluteUrl(options.url) }}">{% endif %}
{% if opengraphImage.alt %}<meta property="og:image:alt" content="{{ opengraphImage.alt }}">{% endif %}
{% endblock %}

@@ -70,7 +70,7 @@
{% endblock %}

{% block bodyEnd %}
<script src="{{ '/assets/govuk.js' | url }}" type="module"></script>
<script src="/assets/govuk.js" type="module"></script>
<script>document.documentElement.classList.remove('no-js')</script>
{% block scripts %}{% endblock %}
{% endblock %}
4 changes: 2 additions & 2 deletions layouts/product.njk
Original file line number Diff line number Diff line change
@@ -10,12 +10,12 @@
html: description | markdown("inline") | noOrphans
} if description,
startButton: {
href: startButton.href | url,
href: startButton.href,
text: startButton.text
} if startButton,
image: {
alt: image.alt,
src: image.src | url
src: image.src
} if image,
breadcrumbs: {
classes: "govuk-!-display-none-print govuk-!-margin-bottom-0",
2 changes: 1 addition & 1 deletion layouts/search-index.njk
Original file line number Diff line number Diff line change
@@ -7,6 +7,6 @@
"hasFrontmatterDate": {{ item.data.date !== undefined }},
"date": {{ item.date | date("d LLLL y") | dump | safe }},
"templateContent": {{ item.templateContent | tokenize | dump | safe }},
"url": {{ item.url | url | pretty | dump | safe }}
"url": {{ item.url | pretty | dump | safe }}
}{% if not loop.last %},{% endif %}
{% endfor %}]
2 changes: 1 addition & 1 deletion layouts/sitemap.njk
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@
{% for item in collections.sitemap | eleventyNavigation(options.homeKey) %}
<div class="govuk-!-margin-bottom-4">
<h2 class="govuk-heading-s govuk-!-margin-bottom-1">
<a class="govuk-link" href="{{ item.url | url | pretty }}">{{ item.title | smart }}</a>
<a class="govuk-link" href="{{ item.url | pretty }}">{{ item.title | smart }}</a>
</h2>
{% if item.excerpt %}
<p class="govuk-body">{{ item.excerpt | markdown("inline") | striptags(true) }}</p>

0 comments on commit c266969

Please sign in to comment.