Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: updated the copyright date #576

Merged
merged 3 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions gulp-tasks/build-nunjucks.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const { packageJson, build } = require('./utils');
// Check for upcoming version number in node env (will be set during release workflow)
const versionNumber = process.env.VERSION_NUMBER || packageJson.version;

// Create a JS date for today, then split into year, month and day (used for copyright and release date)
const d = new Date();
const year = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d);
const month = new Intl.DateTimeFormat('en', { month: 'long' }).format(d);
const day = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(d);

// Merge njk json files together
const mergingJSONFiles = () => {
return src(paths.njkData.src)
Expand All @@ -40,6 +46,8 @@ const manageEnv = env => {
return beautifulHTML;
});

env.addGlobal('currentYear', year); // This is used for the copyright year in the footer, so it is always up to date

// Beautify function shared by the two JS filters below
const beautifyJavascript = js =>
beautifyJS(js.trim(), {
Expand Down Expand Up @@ -107,15 +115,10 @@ const buildingTemplates = () => {
.pipe(plugins.replace('$*cdn', packageJson.buildDirs[build].cdn))
.pipe(plugins.replace('$*version', versionNumber))
.pipe(
// Show todays date in place of the release date
// When the site builds from release this will stay static until the next release
plugins.replace('$*releaseDate', () => {
// Show todays date in place of the release date
// When the site builds from release this will stay static until the next release
const d = new Date();
const ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d);
const mo = new Intl.DateTimeFormat('en', { month: 'long' }).format(d);
const da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(d);

return `${da} ${mo} ${ye}`;
return `${day} ${month} ${year}`;
})
)
.pipe(plugins.formatHtml())
Expand Down
2 changes: 1 addition & 1 deletion src/wmnds/patterns/footer/_footer.njk
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<div class="wmnds-container">
<div class="wmnds-footer__bottom wmnds-grid">
<div class="wmnds-col-1 wmnds-col-md-1-2">
<p class="wmnds-footer__copyright">&copy; West Midlands Combined Authority 2020</p>
<p class="wmnds-footer__copyright">&copy; West Midlands Combined Authority {{currentYear}}</p>
</div>
{% if params.bottomMenu -%}
<div class="wmnds-col-1 wmnds-col-md-1-2">
Expand Down