Skip to content

Commit

Permalink
fix: update sitemap to support localization
Browse files Browse the repository at this point in the history
feat: add YAML linter
  • Loading branch information
greatislander committed Aug 4, 2023
1 parent 68c9f16 commit 36cba24
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 48 deletions.
7 changes: 5 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
"use strict";

module.exports = {
extends: ["fluid"],
ignorePatterns: ["_site/**/*.js", "src/_locales/messages.js", "!.*.cjs", "!.*.js"],
extends: [
"fluid",
"plugin:yml/standard"
],
ignorePatterns: ["_site/", "src/_locales/messages.js", "!.*.cjs", "!.*.js"],
env: {
amd: true,
browser: true,
Expand Down
79 changes: 79 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"lint:css": "stylelint \"**/*.css\"",
"lint:js": "eslint \"**/*.js\"",
"lint:markdown": "markdownlint-cli2 \"**/*.md\"",
"lint:yml": "eslint \"**/*.yml\"",
"start": "run-s clean start:eleventy",
"start:eleventy": "run-p dev cms",
"prepare": "husky install"
Expand Down Expand Up @@ -46,6 +47,7 @@
"eslint": "8.46.0",
"eslint-config-fluid": "2.1.1",
"eslint-plugin-jsdoc": "46.4.5",
"eslint-plugin-yml": "1.8.0",
"husky": "8.0.3",
"image-size": "1.0.2",
"linkedom": "0.15.1",
Expand All @@ -61,7 +63,7 @@
},
"lint-staged": {
"*.css": "stylelint --fix",
"*.js": "eslint --fix",
"*.{js,yml}": "eslint --fix",
"*.md": "markdownlint-cli2 --fix"
}
}
66 changes: 33 additions & 33 deletions src/admin/config.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
backend:
name: git-gateway
branch: main
media_folder: "src/assets/uploads"
public_folder: "/assets/uploads"
media_folder: src/assets/uploads
public_folder: /assets/uploads

# Run "npx netlify-cms-proxy-server" for local backend
local_backend: true
editor:
preview: false
i18n:
structure: multiple_folders
locales: ["en-CA", "fr-CA"]
default_locale: "en-CA"
locales: [en-CA, fr-CA]
default_locale: en-CA
collections:
- label: "Pages"
label_singular: "Page"
name: "page"
- label: Pages
label_singular: Page
name: page
i18n: true
folder: "src/collections/pages/"
extension: "md"
folder: src/collections/pages/
extension: md
create: true
filter: {field: "layout", value: "layouts/page"}
filter: {field: layout, value: layouts/page}
fields:
- { label: "Title", name: "title", widget: "string", i18n: true }
- { label: "Layout", name: "layout", widget: "hidden", i18n: duplicate, default: "layouts/page" }
- { label: "Navigation Order", name: "order", widget: "number", min: 0, i18n: duplicate }
- { label: "Navigation Label", name: "key", widget: "string", required: false, i18n: true }
- { label: "Excerpt", name: "excerpt", widget: "string", required: false, i18n: true }
- { label: "Body", name: "body", widget: "markdown", i18n: true }
- label: "Site Configuration"
name: "config"
- {label: Title, name: title, widget: string, i18n: true}
- {label: Layout, name: layout, widget: hidden, i18n: duplicate, default: layouts/page}
- {label: Navigation Order, name: order, widget: number, min: 0, i18n: duplicate}
- {label: Navigation Label, name: key, widget: string, required: false, i18n: true}
- {label: Excerpt, name: excerpt, widget: string, required: false, i18n: true}
- {label: Body, name: body, widget: markdown, i18n: true}
- label: Site Configuration
name: config
i18n: false
files:
- label: "Site Configuration"
name: "config"
file: "src/_data/config.json"
- label: Site Configuration
name: config
file: src/_data/config.json
fields:
- { label: URL, name: url, widget: string }
- { label: "Maximum Posts in RSS Feed", name: maxPostsInFeed, widget: number, min: 1, i18n: false }
- label: "Site Data"
name: "data"
- {label: URL, name: url, widget: string}
- {label: Maximum Posts in RSS Feed, name: maxPostsInFeed, widget: number, min: 1, i18n: false}
- label: Site Data
name: data
i18n:
structure: single_file
files:
- label: "Site Data"
name: "site"
file: "src/_data/site.json"
- label: Site Data
name: site
file: src/_data/site.json
i18n: true
fields:
- { label: Name, name: name, widget: string, i18n: true }
- { label: Description, name: description, widget: text, i18n: true }
- { label: "Author Name", name: authorName, widget: string, i18n: true }
- { label: "Author Email", name: authorEmail, widget: string, i18n: duplicate }
- { label: "Author Website", name: authorWebsite, widget: string, i18n: duplicate }
- {label: Name, name: name, widget: string, i18n: true}
- {label: Description, name: description, widget: text, i18n: true}
- {label: Author Name, name: authorName, widget: string, i18n: true}
- {label: Author Email, name: authorEmail, widget: string, i18n: duplicate}
- {label: Author Website, name: authorWebsite, widget: string, i18n: duplicate}
23 changes: 11 additions & 12 deletions src/sitemap.njk
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ eleventyExcludeFromCollections: true
<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
{% for page in collections.all %}
{% if page.url -%}
<url>
<loc>{{ site[defaultLanguage].url }}{{ page.url | url }}</loc>
<lastmod>{{ page.date.toISOString() }}</lastmod>
{% for relatedPage in collections.all -%}
{% if page.data.translationKey and page.data.translationKey ===relatedPage.data.translationKey %}
<xhtml:link rel="alternate" hreflang="{{ relatedPage.data.lang}}" href="{{ site[defaultLanguage].url }}{{ relatedPage.url }}"/>
{%- endif %}
{%- endfor %}
</url>
{%- endif %}
{% endfor %}
{%- if page.url and page.data.locale == "en-CA" -%}
<url>
<loc>{{ site[defaultLanguage].url }}{{ page.url | url }}</loc>
<lastmod>{{ page.date.toISOString() }}</lastmod>
{% set links = page.url | locale_links %}
{%- for link in links -%}
<xhtml:link rel="alternate" hreflang="{{ link.lang }}" href="{{ site[defaultLanguage].url }}{{ link.url }}"/>
{%- endfor %}
</url>
{% endif -%}
{%- endfor -%}
</urlset>

0 comments on commit 36cba24

Please sign in to comment.