@apleasantview/eleventy-plugin-baseline 0.1.0-next.32 → 0.1.0-next.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +48 -23
  2. package/core/content-map-store.js +51 -0
  3. package/core/filters/index.js +4 -0
  4. package/core/filters/isString.js +6 -1
  5. package/core/filters/markdown.js +6 -0
  6. package/core/filters/related-posts.js +7 -1
  7. package/core/global-functions/index.js +6 -0
  8. package/core/logging.js +25 -25
  9. package/core/page-context.js +310 -0
  10. package/core/registry.js +110 -0
  11. package/core/schema.js +37 -0
  12. package/core/shortcodes/image.js +167 -144
  13. package/core/shortcodes/index.js +2 -0
  14. package/core/slug-index.js +61 -0
  15. package/core/translation-map-store.js +46 -0
  16. package/core/types.js +73 -0
  17. package/core/utils/helpers.js +75 -0
  18. package/core/utils/pick.js +7 -0
  19. package/core/virtual-dir.js +111 -0
  20. package/core/wikilinks.js +152 -0
  21. package/index.js +364 -0
  22. package/modules/assets/index.js +162 -0
  23. package/modules/assets/processors/esbuild-process.js +35 -0
  24. package/modules/assets/processors/postcss-process.js +52 -0
  25. package/modules/assets/schema.js +14 -0
  26. package/modules/head/drivers/capo-adapter.js +72 -0
  27. package/modules/head/drivers/posthtml-head-elements.js +140 -0
  28. package/modules/head/index.js +106 -0
  29. package/modules/head/schema.js +42 -0
  30. package/modules/head/utils/alternates.js +11 -0
  31. package/modules/head/utils/dedupe.js +47 -0
  32. package/modules/multilang/index.js +149 -0
  33. package/modules/navigator/index.js +140 -0
  34. package/modules/navigator/schema.js +13 -0
  35. package/modules/{navigator-core → navigator}/templates/navigator-core.html +14 -8
  36. package/modules/navigator/utils/debug.js +41 -0
  37. package/modules/sitemap/index.js +121 -0
  38. package/modules/sitemap/templates/sitemap-core.html +34 -0
  39. package/modules/{sitemap-core → sitemap}/templates/sitemap-index.html +2 -2
  40. package/modules.js +6 -0
  41. package/package.json +15 -6
  42. package/core/debug.js +0 -20
  43. package/core/filters.js +0 -9
  44. package/core/globals.js +0 -6
  45. package/core/helpers.js +0 -127
  46. package/core/modules.js +0 -22
  47. package/core/shortcodes.js +0 -3
  48. package/eleventy.config.js +0 -157
  49. package/modules/assets-core/plugins/assets-core.js +0 -84
  50. package/modules/assets-esbuild/filters/inline-esbuild.js +0 -24
  51. package/modules/assets-esbuild/plugins/assets-esbuild.js +0 -71
  52. package/modules/assets-postcss/filters/inline-postcss.js +0 -38
  53. package/modules/assets-postcss/plugins/assets-postcss.js +0 -75
  54. package/modules/head-core/drivers/posthtml-head-elements.js +0 -132
  55. package/modules/head-core/plugins/head-core.js +0 -57
  56. package/modules/head-core/utils/head-utils.js +0 -183
  57. package/modules/multilang-core/plugins/multilang-core.js +0 -101
  58. package/modules/navigator-core/plugins/navigator-core.js +0 -39
  59. package/modules/sitemap-core/plugins/sitemap-core.js +0 -65
  60. package/modules/sitemap-core/templates/sitemap-core.html +0 -25
  61. /package/core/{globals → global-functions}/date.js +0 -0
  62. /package/modules/{assets-postcss/fallback → assets/configs}/postcss.config.js +0 -0
  63. /package/modules/{multilang-core → multilang}/filters/i18n-default-translation.js +0 -0
  64. /package/modules/{multilang-core → multilang}/filters/i18n-translation-in.js +0 -0
  65. /package/modules/{multilang-core → multilang}/filters/i18n-translations-for.js +0 -0
@@ -1,132 +0,0 @@
1
- // Based on posthtml-head-elements (MIT License).
2
- // Original: https://github.com/posthtml/posthtml-head-elements
3
- // Adapted for Baseline head-core.
4
-
5
- // Based on posthtml-head-elements (MIT License).
6
- // Original: https://github.com/posthtml/posthtml-head-elements
7
- // Adapted for Baseline head-core.
8
-
9
- import util from 'node:util';
10
- import { createRequire } from 'node:module';
11
-
12
- const require = createRequire(import.meta.url);
13
-
14
- function nonString(type, attrsArr) {
15
- return attrsArr.map(function (attrs) {
16
- return { tag: type, attrs: attrs };
17
- });
18
- }
19
-
20
- function nonArray(type, content) {
21
- return { tag: type, content: [content] };
22
- }
23
-
24
- function findElmType(type, objectData) {
25
- var elementType = {
26
- meta: function () {
27
- if (Array.isArray(objectData)) {
28
- return nonString(type, objectData);
29
- } else {
30
- util.log('posthtml-head-elements: Please use the correct syntax for a meta element');
31
- }
32
- },
33
- title: function () {
34
- if (typeof objectData === 'string') {
35
- return nonArray('title', objectData);
36
- } else {
37
- util.log('posthtml-head-elements: Please use the correct syntax for a title element');
38
- }
39
- },
40
- link: function () {
41
- if (Array.isArray(objectData)) {
42
- return nonString(type, objectData);
43
- } else {
44
- util.log('posthtml-head-elements: Please use the correct syntax for a link element');
45
- }
46
- },
47
- linkCanonical: function () {
48
- if (Array.isArray(objectData)) {
49
- return nonString('link', objectData);
50
- } else {
51
- util.log('posthtml-head-elements: Please use the correct syntax for a linkCanonical element');
52
- }
53
- },
54
- script: function () {
55
- if (Array.isArray(objectData)) {
56
- return objectData.map(function (entry) {
57
- const { content, ...attrs } = entry || {};
58
- return content !== undefined ? { tag: 'script', attrs, content: [content] } : { tag: 'script', attrs };
59
- });
60
- } else {
61
- util.log('posthtml-head-elements: Please use the correct syntax for a script element');
62
- }
63
- },
64
- style: function () {
65
- if (Array.isArray(objectData)) {
66
- return objectData.map(function (entry) {
67
- const { content, ...attrs } = entry || {};
68
- return content !== undefined ? { tag: 'style', attrs, content: [content] } : { tag: 'style', attrs };
69
- });
70
- } else {
71
- util.log('posthtml-head-elements: Please use the correct syntax for a style element');
72
- }
73
- },
74
- base: function () {
75
- if (Array.isArray(objectData)) {
76
- return nonString(type, objectData);
77
- } else {
78
- util.log('posthtml-head-elements: Please use the correct syntax for a base element');
79
- }
80
- },
81
- default: function () {
82
- util.log('posthtml-head-elements: Please make sure the HTML head type is correct');
83
- }
84
- };
85
-
86
- if (type.indexOf('_') !== -1) {
87
- type = type.substr(0, type.indexOf('_'));
88
- }
89
-
90
- return elementType[type]() || elementType['default']();
91
- }
92
-
93
- function buildNewTree(headElements, EOL) {
94
- var newHeadElements = [];
95
-
96
- Object.keys(headElements).forEach(function (value) {
97
- newHeadElements.push(findElmType(value, headElements[value]));
98
- });
99
-
100
- function cnct(arr) {
101
- return Array.prototype.concat.apply([], arr);
102
- }
103
-
104
- return cnct(
105
- cnct(newHeadElements).map(function (elem) {
106
- return [elem, EOL];
107
- })
108
- );
109
- }
110
-
111
- export default function (options) {
112
- options = options || {};
113
- options.headElementsTag = options.headElementsTag || 'posthtml-head-elements';
114
-
115
- if (!options.headElements) {
116
- util.log(
117
- "posthtml-head-elements: Don't forget to add a link to the JSON file containing the head elements to insert"
118
- );
119
- }
120
- var jsonOne = typeof options.headElements !== 'string' ? options.headElements : require(options.headElements);
121
-
122
- return function posthtmlHeadElements(tree) {
123
- tree.match({ tag: options.headElementsTag }, function () {
124
- return {
125
- tag: false, // delete this node, safe content
126
- content: buildNewTree(jsonOne, options.EOL || '\n')
127
- };
128
- });
129
-
130
- return tree;
131
- };
132
- }
@@ -1,57 +0,0 @@
1
- import headElements from '../drivers/posthtml-head-elements.js';
2
- import { getVerbose, logIfVerbose } from '../../../core/logging.js';
3
- import { buildHead } from '../utils/head-utils.js';
4
-
5
- /** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
6
- export default function headCore(eleventyConfig, options = {}) {
7
- const verbose = getVerbose(eleventyConfig) || options.verbose || false;
8
-
9
- // Following options are not public.
10
- const userKey = options.dirKey || 'head';
11
- const headElementsTag = options.headElementsTag || 'baseline-head';
12
- const eol = options.EOL || '\n';
13
- const pathPrefix = options.pathPrefix ?? eleventyConfig?.pathPrefix ?? '';
14
- const siteUrl = options.siteUrl;
15
-
16
- let cachedContentMap = {};
17
- eleventyConfig.on('eleventy.contentMap', ({ inputPathToUrl, urlToInputPath }) => {
18
- cachedContentMap = { inputPathToUrl, urlToInputPath };
19
- });
20
-
21
- eleventyConfig.addGlobalData('eleventyComputed.page.head', () => {
22
- return (data) =>
23
- buildHead(data, {
24
- userKey,
25
- siteUrl,
26
- pathPrefix,
27
- contentMap: cachedContentMap,
28
- pageUrlOverride: data?.page?.url,
29
- verbose
30
- });
31
- });
32
-
33
- eleventyConfig.htmlTransformer.addPosthtmlPlugin('html', function (context) {
34
- logIfVerbose(verbose, 'head-core: injecting head elements for', context?.page?.inputPath || context?.outputPath);
35
-
36
- const headElementsSpec =
37
- context?.page?.head ||
38
- buildHead(context, {
39
- userKey,
40
- siteUrl,
41
- pathPrefix,
42
- contentMap: cachedContentMap,
43
- pageUrlOverride: context?.page?.url,
44
- verbose
45
- });
46
-
47
- const plugin = headElements({
48
- headElements: headElementsSpec,
49
- headElementsTag,
50
- EOL: eol
51
- });
52
-
53
- return async function asyncHead(tree) {
54
- return plugin(tree);
55
- };
56
- });
57
- }
@@ -1,183 +0,0 @@
1
- import Merge from '@11ty/eleventy-utils/src/Merge.js';
2
- import { TemplatePath } from '@11ty/eleventy-utils';
3
-
4
- const pick = (...values) => values.find((v) => v !== undefined && v !== null);
5
-
6
- const normalizePathPrefix = (pathPrefix = '') => {
7
- // Align with Eleventy’s normalizeUrlPath behavior
8
- const normalized = TemplatePath.normalizeUrlPath('/', pathPrefix);
9
- return normalized === '/' ? '' : normalized; // empty means root
10
- };
11
-
12
- const isAbsoluteUrl = (url = '') => /^[a-z][a-z\d+\-.]*:\/\//i.test(url) || url.startsWith('//');
13
-
14
- const absoluteUrl = (siteUrl, pathPrefix, url) => {
15
- if (!url) return url;
16
- if (isAbsoluteUrl(url)) return url;
17
- const prefix = normalizePathPrefix(pathPrefix);
18
- const joined = TemplatePath.normalizeUrlPath(prefix || '/', url);
19
- return siteUrl ? `${siteUrl.replace(/\/+$/, '')}${joined}` : joined;
20
- };
21
-
22
- const mergeBaseHead = (site, user, page, title, description, noindex, url) => {
23
- return Merge(
24
- {},
25
- {
26
- title,
27
- meta: [
28
- { charset: 'UTF-8' },
29
- { name: 'viewport', content: 'width=device-width, initial-scale=1.0' },
30
- { name: 'description', content: description },
31
- { name: 'robots', content: noindex ? 'noindex, nofollow' : 'index, follow' }
32
- ],
33
- link: [],
34
- script: [],
35
- style: [],
36
- hreflang: [],
37
- openGraph: {
38
- 'og:title': title,
39
- 'og:description': description,
40
- 'og:type': 'website',
41
- 'og:url': url || '',
42
- 'og:image': ''
43
- },
44
- twitter: {
45
- 'twitter:card': 'summary_large_image',
46
- 'twitter:title': title,
47
- 'twitter:description': description,
48
- 'twitter:image': ''
49
- },
50
- miscMeta: [],
51
- structuredData: null
52
- },
53
- user
54
- );
55
- };
56
-
57
- const resolveCanonical = (head, page, contentMap, env = {}) => {
58
- const { siteUrl, pathPrefix = '', pageUrlOverride, verbose } = env;
59
- const explicit = pick(head.canonical);
60
- if (explicit) {
61
- if (!siteUrl && verbose) {
62
- console.warn('[baseline] site.url is missing; canonical will be relative.');
63
- }
64
- return absoluteUrl(siteUrl, pathPrefix, explicit);
65
- }
66
-
67
- const url = pick(pageUrlOverride, page?.url, page?.inputPath && contentMap?.inputPathToUrl?.[page.inputPath]?.[0]);
68
- if (!url) return undefined;
69
-
70
- if (!siteUrl && verbose) {
71
- console.warn('[baseline] site.url is missing; canonical will be relative.');
72
- }
73
-
74
- return absoluteUrl(siteUrl, pathPrefix, url);
75
- };
76
-
77
- const dedupeMeta = (arr = []) => {
78
- const seen = new Set();
79
- const out = [];
80
- for (let i = arr.length - 1; i >= 0; i--) {
81
- const m = arr[i];
82
- const key = m.charset
83
- ? 'charset'
84
- : m.name
85
- ? `name:${m.name}`
86
- : m.property
87
- ? `prop:${m.property}`
88
- : m['http-equiv']
89
- ? `http:${m['http-equiv']}`
90
- : null;
91
- if (!key || seen.has(key)) continue;
92
- seen.add(key);
93
- out.push(m);
94
- }
95
- return out.reverse();
96
- };
97
-
98
- const dedupeLink = (links = []) => {
99
- const seen = new Set();
100
- const out = [];
101
- for (let i = links.length - 1; i >= 0; i--) {
102
- const l = links[i];
103
- const key = l.rel && l.href ? `rel:${l.rel}|${l.href}` : null;
104
- if (!key || seen.has(key)) continue;
105
- seen.add(key);
106
- out.push(l);
107
- }
108
- return out.reverse();
109
- };
110
-
111
- const flattenHead = (head = {}, canonical) => {
112
- // base/meta first, keep OG/Twitter last by placing them in a separate meta bucket
113
- const baseMeta = dedupeMeta([...(head.meta || []), ...(head.miscMeta || [])]);
114
-
115
- const socialMeta = dedupeMeta([
116
- ...(head.openGraph
117
- ? Object.entries(head.openGraph)
118
- .filter(([, v]) => v)
119
- .map(([k, v]) => ({ property: k, content: v }))
120
- : []),
121
- ...(head.twitter
122
- ? Object.entries(head.twitter)
123
- .filter(([, v]) => v)
124
- .map(([k, v]) => ({ name: k, content: v }))
125
- : [])
126
- ]);
127
-
128
- const style = [...(head.style || [])];
129
-
130
- const linkCanonical = canonical ? [{ rel: 'canonical', href: canonical }] : [];
131
- const link = dedupeLink([...(head.link || []), ...(head.hreflang || [])].filter(Boolean));
132
-
133
- const script = [...(head.script || [])];
134
- if (head.structuredData) {
135
- script.unshift({
136
- type: 'application/ld+json',
137
- content: JSON.stringify(head.structuredData)
138
- });
139
- }
140
-
141
- // Key order matters for posthtml-head-elements.
142
- return {
143
- meta: baseMeta,
144
- title: head.title || '',
145
- linkCanonical,
146
- style,
147
- link,
148
- script,
149
- meta_social: socialMeta
150
- };
151
- };
152
-
153
- const buildHead = (data = {}, env = {}) => {
154
- const { userKey = 'head', contentMap = {}, siteUrl, pathPrefix } = env;
155
- const site = data.site || {};
156
- const user = userKey ? data[userKey] || {} : {};
157
- const page = data.page || {};
158
- const resolvedSiteUrl =
159
- siteUrl || site.url || process.env.URL || process.env.DEPLOY_URL || process.env.DEPLOY_PRIME_URL;
160
-
161
- const siteTitle = site.title || '';
162
- const pageTitle = pick(data.title, user.title, site.title, '');
163
- const title =
164
- siteTitle && pageTitle && siteTitle !== pageTitle ? `${pageTitle} | ${siteTitle}` : pageTitle || siteTitle || '';
165
-
166
- const description = pick(data.description, user.description, site.tagline, '');
167
- const noindex = pick(data.noindex, page.noindex, user.noindex, site.noindex, false);
168
-
169
- const canonical = resolveCanonical(
170
- { canonical: absoluteUrl(resolvedSiteUrl, pathPrefix, user.canonical) },
171
- page,
172
- contentMap,
173
- { ...env, siteUrl: resolvedSiteUrl, verbose: env.verbose }
174
- );
175
- const merged = mergeBaseHead(site, user, page, title, description, noindex, canonical);
176
- return flattenHead(merged, canonical);
177
- };
178
-
179
- const buildHeadSpec = (context, contentMap, env = {}) => {
180
- return buildHead(context, { ...env, contentMap });
181
- };
182
-
183
- export { pick, resolveCanonical, flattenHead, buildHead, buildHeadSpec, absoluteUrl };
@@ -1,101 +0,0 @@
1
- import { I18nPlugin } from '@11ty/eleventy';
2
- import { DeepCopy } from '@11ty/eleventy-utils';
3
- import i18nTranslationsFor from '../filters/i18n-translations-for.js';
4
- import i18nTranslationIn from '../filters/i18n-translation-in.js';
5
- import i18nDefaultTranslation from '../filters/i18n-default-translation.js';
6
-
7
- /**
8
- * Baseline – multilang-core
9
- *
10
- * Responsibilities:
11
- * - Normalize language metadata
12
- * - Annotate translatable pages
13
- * - Expose relational helpers for translations
14
- *
15
- * @param { import("@11ty/eleventy/src/UserConfig.js").default } eleventyConfig
16
- */
17
- export default function multilangCore(eleventyConfig, options = {}) {
18
- const userOptions = {
19
- defaultLanguage: 'en',
20
- languages: [],
21
- verbose: false,
22
- ...options
23
- };
24
-
25
- eleventyConfig.addPlugin(I18nPlugin, {
26
- defaultLanguage: userOptions.defaultLanguage,
27
- errorMode: 'allow-fallback'
28
- });
29
-
30
- // Normalize allowed languages (optionally lower/trim)
31
- const normalizeLang = (lang) => (lang || '').toLowerCase().trim();
32
- const allowedLanguages = new Set(
33
- Array.isArray(userOptions.languages)
34
- ? userOptions.languages.map(normalizeLang)
35
- : Object.keys(userOptions.languages || {}).map(normalizeLang)
36
- );
37
-
38
- eleventyConfig.addGlobalData('eleventyComputed.page.locale', () => {
39
- return (data) => {
40
- const lang = normalizeLang(data.lang || data.language || userOptions.defaultLanguage);
41
- const translationKey = data.translationKey;
42
- const isDefaultLang = lang === normalizeLang(userOptions.defaultLanguage);
43
-
44
- return {
45
- translationKey,
46
- lang,
47
- isDefaultLang
48
- };
49
- };
50
- });
51
-
52
- const buildTranslations = (collection) => {
53
- const map = {};
54
- const list = [];
55
-
56
- for (const page of collection.getAll()) {
57
- const translationKey = page.data.translationKey;
58
- if (!translationKey) continue;
59
-
60
- const lang = page.data.lang || page.data.language || userOptions.defaultLanguage;
61
- if (!lang) continue;
62
-
63
- if (allowedLanguages.size && !allowedLanguages.has(lang)) {
64
- if (userOptions.verbose) {
65
- console.warn(`[baseline:multilang-core] Unknown lang "${lang}" in ${page.inputPath}`);
66
- }
67
- continue;
68
- }
69
-
70
- const locale = { locale: { translationKey, lang, isDefaultLang: lang === userOptions.defaultLanguage } };
71
- const safeCopy = DeepCopy(page, locale);
72
- list.push(safeCopy);
73
-
74
- if (!map[translationKey]) map[translationKey] = {};
75
- map[translationKey][lang] = {
76
- title: page.data.title,
77
- url: page.url,
78
- lang,
79
- isDefaultLang: lang === userOptions.defaultLanguage,
80
- data: page.data
81
- };
82
- }
83
-
84
- return { map, list };
85
- };
86
-
87
- // Map form for direct lookups
88
- eleventyConfig.addCollection('translationsMap', (collection) => {
89
- return buildTranslations(collection).map;
90
- });
91
-
92
- // Canonical translations collection
93
- eleventyConfig.addCollection('translations', (collection) => {
94
- return buildTranslations(collection).list;
95
- });
96
-
97
- // Filters – relational helpers
98
- eleventyConfig.addFilter('i18nTranslationsFor', i18nTranslationsFor);
99
- eleventyConfig.addFilter('i18nTranslationIn', i18nTranslationIn);
100
- eleventyConfig.addFilter('i18nDefaultTranslation', i18nDefaultTranslation);
101
- }
@@ -1,39 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
-
5
- const __filename = fileURLToPath(import.meta.url);
6
- const __dirname = path.dirname(__filename);
7
-
8
- /** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
9
- export default function navigatorCore(eleventyConfig, options = {}) {
10
- const raw = options.enableNavigatorTemplate;
11
- const [enableNavigatorTemplate, inspectorDepth] = Array.isArray(raw) ? [raw[0], raw[1]] : [raw, undefined];
12
-
13
- const userOptions = {
14
- ...options,
15
- enableNavigatorTemplate: enableNavigatorTemplate ?? false,
16
- inspectorDepth: inspectorDepth ?? 2
17
- };
18
-
19
- eleventyConfig.addNunjucksGlobal('_navigator', function () {
20
- return this;
21
- });
22
- eleventyConfig.addNunjucksGlobal('_context', function () {
23
- return this.ctx;
24
- });
25
-
26
- if (userOptions.enableNavigatorTemplate) {
27
- // Read virtual template synchronously; Nunjucks pipeline here is sync-only.
28
- const templatePath = path.join(__dirname, '../templates/navigator-core.html');
29
- const virtualTemplateContent = fs.readFileSync(templatePath, 'utf-8');
30
- eleventyConfig.addTemplate('navigator-core.html', virtualTemplateContent, {
31
- permalink: '/navigator-core.html',
32
- title: 'Navigator Core',
33
- description: '',
34
- layout: null,
35
- eleventyExcludeFromCollections: true,
36
- inspectorDepth: userOptions.inspectorDepth
37
- });
38
- }
39
- }
@@ -1,65 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
-
5
- const __filename = fileURLToPath(import.meta.url);
6
- const __dirname = path.dirname(__filename);
7
-
8
- /** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
9
- export default function sitemapCore(eleventyConfig, options = {}) {
10
- const userOptions = {
11
- enableSitemapTemplate: options.enableSitemapTemplate ?? true,
12
- multilingual: options.multilingual,
13
- languages: options.languages
14
- };
15
-
16
- eleventyConfig.addGlobalData('eleventyComputed.page.sitemap', () => {
17
- return (data) => ({
18
- ignore: data.noindex ?? data.page?.noindex ?? data.site?.noindex ?? false,
19
- changefreq: '',
20
- priority: -1
21
- });
22
- });
23
-
24
- if (userOptions.enableSitemapTemplate) {
25
- const templatePath = path.join(__dirname, '../templates/sitemap-core.html');
26
- const indexTemplatePath = path.join(__dirname, '../templates/sitemap-index.html');
27
- const baseContent = fs.readFileSync(templatePath, 'utf-8');
28
- const indexContent = fs.readFileSync(indexTemplatePath, 'utf-8');
29
-
30
- const languages = userOptions.languages || {};
31
- const langKeys = Array.isArray(languages) ? languages : Object.keys(languages);
32
- const multilingual = typeof userOptions.multilingual === 'boolean' ? userOptions.multilingual : langKeys.length > 1;
33
-
34
- if (multilingual && langKeys.length > 1) {
35
- for (const lang of langKeys) {
36
- eleventyConfig.addTemplate(`_baseline/sitemap-core-${lang}.html`, baseContent, {
37
- permalink: `${lang}/sitemap.xml`,
38
- title: '',
39
- description: '',
40
- layout: null,
41
- eleventyExcludeFromCollections: true,
42
- isMultilingual: multilingual,
43
- sitemapLang: lang
44
- });
45
- }
46
-
47
- eleventyConfig.addTemplate('_baseline/sitemap-index.html', indexContent, {
48
- permalink: '/sitemap.xml',
49
- title: '',
50
- description: '',
51
- layout: null,
52
- eleventyExcludeFromCollections: true,
53
- isMultilingual: multilingual
54
- });
55
- } else {
56
- eleventyConfig.addTemplate('_baseline/sitemap-core.html', baseContent, {
57
- permalink: '/sitemap.xml',
58
- title: '',
59
- description: '',
60
- layout: null,
61
- eleventyExcludeFromCollections: true
62
- });
63
- }
64
- }
65
- }
@@ -1,25 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8" standalone="yes"?>
2
- <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
3
- {%- if not site.noindex -%}
4
- {%- for item in collections.all -%}
5
- {%- if not item.data.eleventyExcludeFromCollections and (not item.data.sitemap or item.data.sitemap.ignore != true) and item.data.noindex != true -%}
6
- {%- set pageLang = item.data.lang or site.defaultLanguage -%}
7
- {%- if (not isMultilingual) or (not sitemapLang) or (pageLang == sitemapLang) -%}
8
- {%- set absoluteUrl = item.url | htmlBaseUrl -%}
9
- {%- set lastmod = item.data.sitemap and item.data.sitemap.lastmod or item.date -%}
10
- <url>
11
- <loc>{{ absoluteUrl }}</loc>
12
- {%- if lastmod -%}<lastmod>{{ date.toUTCISO(lastmod) }}</lastmod>{%- endif -%}
13
- {%- if item.data.sitemap and item.data.sitemap.changefreq -%}<changefreq>{{ item.data.sitemap.changefreq }}</changefreq>{%- endif -%}
14
- {%- if item.data.sitemap and item.data.sitemap.priority is defined -%}<priority>{{ item.data.sitemap.priority }}</priority>{%- endif -%}
15
- {%- if item.data.translationKey and collections.translationsMap and collections.translationsMap[item.data.translationKey] -%}
16
- {%- for language, entry in collections.translationsMap[item.data.translationKey] -%}
17
- <xhtml:link rel="alternate" hreflang="{{ entry.lang }}" href="{{ entry.url | htmlBaseUrl }}" />
18
- {%- endfor -%}
19
- {%- endif -%}
20
- </url>
21
- {%- endif -%}
22
- {%- endif -%}
23
- {%- endfor -%}
24
- {%- endif -%}
25
- </urlset>
File without changes