Skip to content

Commit

Permalink
Add sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
pfreitag committed Jan 28, 2020
1 parent 45f34ce commit 6fe70c6
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
const { DateTime } = require("luxon");

module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy("www/css");
eleventyConfig.addPassthroughCopy("www/js");
eleventyConfig.addPassthroughCopy("www/favicon.ico");
eleventyConfig.addPassthroughCopy("www/robots.txt");

//used for sitemap
eleventyConfig.addFilter('htmlDateString', (dateObj) => {
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd');
});


return {
passthroughFileCopy: true,
dir: {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"devDependencies": {
"@11ty/eleventy": "^0.10.0"
"@11ty/eleventy": "^0.10.0",
"luxon": "^1.21.3"
}
}
3 changes: 3 additions & 0 deletions www/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
---
date: Last Modified
---
<!DOCTYPE html>
<html lang="en">
<head>
Expand Down
1 change: 1 addition & 0 deletions www/nonce.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: Using a nonce in CSP
layout: layout
date: Last Modified
---
<div class="jumbotron">
<h1>Using a <code>nonce</code> with CSP</h1>
Expand Down
4 changes: 3 additions & 1 deletion www/robots.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
User-agent: *
Disallow:
Disallow:

Sitemap: https://content-security-policy.com/sitemap.xml
1 change: 1 addition & 0 deletions www/script-src.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: script-src CSP Directive
layout: layout
date: Last Modified
---
<div class="jumbotron">
<h1>The <code>script-src</code> Directive</h1>
Expand Down
14 changes: 14 additions & 0 deletions www/sitemap.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
permalink: /sitemap.xml
eleventyExcludeFromCollections: true
---
<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{%- for page in collections.all %}
{% set mappedUrl %}{{ metadata.url}}{{ page.url | url }}{% endset %}
<url>
<loc>https://content-security-policy.com{{ mappedUrl }}</loc>
<lastmod>{{ page.date | htmlDateString }}</lastmod>
</url>
{%- endfor %}
</urlset>

0 comments on commit 6fe70c6

Please sign in to comment.