From cce838e2c06e0991379d7b06bfa517059bc3a4a0 Mon Sep 17 00:00:00 2001 From: Cassie Jones Date: Sat, 2 Nov 2019 01:25:12 -0400 Subject: [PATCH] Add more page setup stuff --- .eleventy.js | 43 ++++++++++- _includes/layouts/layout.njk | 31 +++++++- _includes/layouts/post.njk | 2 +- index.html | 7 -- index.njk | 12 +++ package-lock.json | 139 ++++++++++++++++++++--------------- package.json | 7 +- 7 files changed, 167 insertions(+), 74 deletions(-) delete mode 100644 index.html create mode 100644 index.njk diff --git a/.eleventy.js b/.eleventy.js index f3ea133..3d62916 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -2,9 +2,46 @@ const pluginRss = require("@11ty/eleventy-plugin-rss"); const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight"); const Nunjucks = require("nunjucks"); const nunjucksDate = require("nunjucks-date"); +const md = require("markdown-it")(); module.exports = (eleventyConfig) => { - eleventyConfig.addNunjucksFilter('date', nunjucksDate); - eleventyConfig.addPlugin(pluginRss); - eleventyConfig.addPlugin(pluginSyntaxHighlight); + eleventyConfig.addNunjucksFilter('date', nunjucksDate); + eleventyConfig.addPlugin(pluginRss); + eleventyConfig.addPlugin(pluginSyntaxHighlight); + + eleventyConfig.addNunjucksShortcode("youtube", youtubeShortcode); + eleventyConfig.addPairedNunjucksShortcode("tweet", tweetShortcode); + eleventyConfig.addFilter("markdown", value => md.renderInline(value)); + + return { + markdownTemplateEngine: "njk", + }; }; + +function youtubeShortcode(items, inWidth, inHeight) { + const width = items.width || inWidth || 560; + const height = items.height || inHeight || 315; + const allow = items.allow || "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" + const border = items.border || "0"; + const video = items.video || items; + if (!video) { + throw "Required argument 'video'."; + } + const src = "https://www.youtube.com/embed/" + video; + return `
+ +
`; +} + +function tweetShortcode(content, items) { + // @TODO: Handle parsing date + return `
+ + +
`; +} diff --git a/_includes/layouts/layout.njk b/_includes/layouts/layout.njk index 28e1a1e..b738c1c 100644 --- a/_includes/layouts/layout.njk +++ b/_includes/layouts/layout.njk @@ -3,8 +3,37 @@ Witch of Light + - + +
+

Witch of Light

+ A collection of Cassie's harebrained schemes. +
{{ content | safe }} +
+ diff --git a/_includes/layouts/post.njk b/_includes/layouts/post.njk index 7ee5785..77dc832 100644 --- a/_includes/layouts/post.njk +++ b/_includes/layouts/post.njk @@ -1,6 +1,6 @@ --- layout: "layouts/layout.njk" -permalink: "/{{ page.date | date: '%Y' }}/{{ page.fileSlug }}/index.html" +permalink: "/{{ page.date | date('YYYY') }}/{{ page.fileSlug }}/index.html" ---
diff --git a/index.html b/index.html deleted file mode 100644 index a46a32c..0000000 --- a/index.html +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: "layouts/layout.njk" ---- -{% for post in collections.posts %} -

{{ post.data.title }}

- Hello Post Right Here -{% endfor %} diff --git a/index.njk b/index.njk new file mode 100644 index 0000000..c824c59 --- /dev/null +++ b/index.njk @@ -0,0 +1,12 @@ +--- +layout: "layouts/layout.njk" +--- +
    +{% for post in collections.posts | reverse %} +
  • +

    {{ post.data.title }}

    + {{ post.date | date("YYYY-MM-DD") }} +

    {{ post.data.summary | markdown | safe }}

    +
  • +{% endfor %} +
diff --git a/package-lock.json b/package-lock.json index 16f33b9..369e814 100644 --- a/package-lock.json +++ b/package-lock.json @@ -125,6 +125,19 @@ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true }, + "markdown-it": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-8.4.2.tgz", + "integrity": "sha512-GcRz3AWTqSUphY3vsUqQSFMbgR38a4Lh3GWlHRh/7MRwz8mcu9n2IO7HOh+bXHrR9kOPDl5RNCaEsrneb+xhHQ==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "entities": "~1.1.1", + "linkify-it": "^2.0.0", + "mdurl": "^1.0.1", + "uc.micro": "^1.0.5" + } + }, "readdirp": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.2.0.tgz", @@ -158,12 +171,64 @@ } }, "@11ty/eleventy-plugin-syntaxhighlight": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@11ty/eleventy-plugin-syntaxhighlight/-/eleventy-plugin-syntaxhighlight-2.0.3.tgz", - "integrity": "sha512-tPoNaEawOG1kkOYAvr4fwKaMOXRhNueOH7z5aepA0vjfnGCagUlSbUipvjCcUUOf+nQgfJYW2rwR2g97Vv8/rg==", + "version": "file:../../oss/eleventy-plugin-syntaxhighlight", "dev": true, "requires": { "prismjs": "^1.15.0" + }, + "dependencies": { + "clipboard": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.4.tgz", + "integrity": "sha512-Vw26VSLRpJfBofiVaFb/I8PVfdI1OxKcYShe6fm0sP/DtmiWQNCjhM/okTvdCo0G+lMMm1rMYbk4IK4x1X+kgQ==", + "dev": true, + "optional": true, + "requires": { + "good-listener": "^1.2.2", + "select": "^1.1.2", + "tiny-emitter": "^2.0.0" + } + }, + "delegate": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz", + "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==", + "dev": true, + "optional": true + }, + "good-listener": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz", + "integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=", + "dev": true, + "optional": true, + "requires": { + "delegate": "^3.1.2" + } + }, + "prismjs": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.17.1.tgz", + "integrity": "sha512-PrEDJAFdUGbOP6xK/UsfkC5ghJsPJviKgnQOoxaDbBjwc8op68Quupwt1DeAFoG8GImPhiKXAvvsH7wDSLsu1Q==", + "dev": true, + "requires": { + "clipboard": "^2.0.0" + } + }, + "select": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz", + "integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=", + "dev": true, + "optional": true + }, + "tiny-emitter": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", + "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==", + "dev": true, + "optional": true + } } }, "@babel/parser": { @@ -920,18 +985,6 @@ } } }, - "clipboard": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.4.tgz", - "integrity": "sha512-Vw26VSLRpJfBofiVaFb/I8PVfdI1OxKcYShe6fm0sP/DtmiWQNCjhM/okTvdCo0G+lMMm1rMYbk4IK4x1X+kgQ==", - "dev": true, - "optional": true, - "requires": { - "good-listener": "^1.2.2", - "select": "^1.1.2", - "tiny-emitter": "^2.0.0" - } - }, "cliui": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", @@ -1205,13 +1258,6 @@ "rimraf": "^2.2.8" } }, - "delegate": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz", - "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==", - "dev": true, - "optional": true - }, "depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", @@ -2728,16 +2774,6 @@ } } }, - "good-listener": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz", - "integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=", - "dev": true, - "optional": true, - "requires": { - "delegate": "^3.1.2" - } - }, "graceful-fs": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", @@ -3524,16 +3560,24 @@ } }, "markdown-it": { - "version": "8.4.2", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-8.4.2.tgz", - "integrity": "sha512-GcRz3AWTqSUphY3vsUqQSFMbgR38a4Lh3GWlHRh/7MRwz8mcu9n2IO7HOh+bXHrR9kOPDl5RNCaEsrneb+xhHQ==", + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-10.0.0.tgz", + "integrity": "sha512-YWOP1j7UbDNz+TumYP1kpwnP0aEa711cJjrAQrzd0UXlbJfc5aAq0F/PZHjiioqDC1NKgvIMX+o+9Bk7yuM2dg==", "dev": true, "requires": { "argparse": "^1.0.7", - "entities": "~1.1.1", + "entities": "~2.0.0", "linkify-it": "^2.0.0", "mdurl": "^1.0.1", "uc.micro": "^1.0.5" + }, + "dependencies": { + "entities": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.0.0.tgz", + "integrity": "sha512-D9f7V0JSRwIxlRI2mjMqufDrRDnx8p+eEOz7aUM9SuvF8gsBzra0/6tbjl1m8eQHrZlYj6PxqE00hZ1SAIKPLw==", + "dev": true + } } }, "maximatch": { @@ -4375,15 +4419,6 @@ "parse-ms": "^0.1.0" } }, - "prismjs": { - "version": "1.17.1", - "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.17.1.tgz", - "integrity": "sha512-PrEDJAFdUGbOP6xK/UsfkC5ghJsPJviKgnQOoxaDbBjwc8op68Quupwt1DeAFoG8GImPhiKXAvvsH7wDSLsu1Q==", - "dev": true, - "requires": { - "clipboard": "^2.0.0" - } - }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -4942,13 +4977,6 @@ } } }, - "select": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz", - "integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=", - "dev": true, - "optional": true - }, "semver": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", @@ -5745,13 +5773,6 @@ } } }, - "tiny-emitter": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", - "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==", - "dev": true, - "optional": true - }, "to-array": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", diff --git a/package.json b/package.json index 632942b..3b4a808 100644 --- a/package.json +++ b/package.json @@ -5,10 +5,11 @@ "main": ".eleventy.js", "dependencies": {}, "devDependencies": { - "@11ty/eleventy-plugin-rss": "^1.0.7", - "nunjucks-date": "^1.4.0", "@11ty/eleventy": "^0.9.0", - "@11ty/eleventy-plugin-syntaxhighlight": "^2.0.3" + "@11ty/eleventy-plugin-rss": "^1.0.7", + "@11ty/eleventy-plugin-syntaxhighlight": "file:../../oss/eleventy-plugin-syntaxhighlight", + "markdown-it": "^8.4.2", + "nunjucks-date": "^1.4.0" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" -- 2.47.0