-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathpages.11tydata.js
32 lines (30 loc) · 1.36 KB
/
pages.11tydata.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"use strict";
const i18n = require("eleventy-plugin-i18n-gettext");
const { generatePermalink } = require("eleventy-plugin-fluid");
module.exports = {
/* Build a permalink using the page title and language. */
permalink: data => {
const locale = data.locale;
return generatePermalink(data, "pages", false, i18n._(locale, "page"));
},
layout: "layouts/page.njk",
eleventyComputed: {
eleventyNavigation: data => {
if (Object.prototype.hasOwnProperty.call(data, "eleventyNavigation") && Object.prototype.hasOwnProperty.call(data.eleventyNavigation, "key")) {
/* If this page has `eleventyNavigation` front-matter set, use that */
return data.eleventyNavigation;
} else if (data.order) {
/* If this page has an `order` attribute, create an Eleventy Navigation object for it. */
return {
parent: data.locale,
order: data.order,
/* If a key is set, use that for the navigation item label; otherwise use the page title. */
key: Object.prototype.hasOwnProperty.call(data, "key") ? data.key : data.title
};
}
return false;
},
lang: data => data.locale,
langDir: data => data.supportedLanguages[data.locale].dir
}
};