From f37d0b3571e684ddb02b3ea6673a8fec676803e0 Mon Sep 17 00:00:00 2001 From: Devin Haska Date: Fri, 1 Mar 2024 11:35:08 -0800 Subject: [PATCH] feat: add decap cms for editing content --- config/collections/index.js | 2 +- eleventy.config.js | 4 +- src/_data/preloads.js | 2 +- src/about.md | 1 + src/admin/config.njk | 84 ++++++++++++++++++++++++++++++++++++ src/admin/index.html | 17 ++++++++ src/colophon.md | 1 + src/css-utils/font-family.js | 4 +- src/links.md | 1 + src/uses.md | 1 + src/utils/fonts.js | 7 +++ 11 files changed, 117 insertions(+), 7 deletions(-) create mode 100644 src/admin/config.njk create mode 100644 src/admin/index.html create mode 100644 src/utils/fonts.js diff --git a/config/collections/index.js b/config/collections/index.js index 3cc0c44..3149ab1 100644 --- a/config/collections/index.js +++ b/config/collections/index.js @@ -30,6 +30,6 @@ const catalogueByType = (collection) => { }; module.exports = { - postsByTag, catalogueByType, + postsByTag, }; diff --git a/eleventy.config.js b/eleventy.config.js index 1a6adbf..95ede1b 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -1,8 +1,8 @@ const pluginRss = require("@11ty/eleventy-plugin-rss"); const { - postsByTag, catalogueByType, + postsByTag, } = require("./config/collections/index.js"); const { dir } = require("./config/constants.js"); const { @@ -29,8 +29,8 @@ module.exports = (eleventyConfig) => { eleventyConfig.addPlugin(pluginRss); // --------------------- Custom Collections ----------------------- - eleventyConfig.addCollection("postsByTag", postsByTag); eleventyConfig.addCollection("catalogueByType", catalogueByType); + eleventyConfig.addCollection("postsByTag", postsByTag); // --------------------- Custom Filters ----------------------- eleventyConfig.addFilter("allTagCounts", allTagCounts); diff --git a/src/_data/preloads.js b/src/_data/preloads.js index 1e21ac8..3f00dff 100644 --- a/src/_data/preloads.js +++ b/src/_data/preloads.js @@ -1,4 +1,4 @@ -const { getFontUrl } = require("../../config/utils"); +const { getFontUrl } = require("../utils/fonts"); const fonts = require("../../config/design-tokens/fonts.json"); const preloads = [ diff --git a/src/about.md b/src/about.md index 022ab67..1db195f 100644 --- a/src/about.md +++ b/src/about.md @@ -2,6 +2,7 @@ layout: "layouts/base" permalink: /about/index.html title: About +tags: ["page"] --- Hello! Ahoj! Welcome to my site! diff --git a/src/admin/config.njk b/src/admin/config.njk new file mode 100644 index 0000000..ce4b25f --- /dev/null +++ b/src/admin/config.njk @@ -0,0 +1,84 @@ +--- +permalink: /admin/config.yml +--- + +backend: + name: github + repo: wonderfulfrog/wonderfulfrog.com + branch: main + +media_folder: "" + +collections: + - name: "post" + label: "Post" + folder: "src/posts" + create: true + fields: + - { label: "Title", name: "title", widget: "string" } + - { label: "Excerpt", name: "excerpt", widget: "string" } + - { label: "Tags", name: "tags", widget: "list" } + - { label: "Using YouTube", name: "youtube", widget: "boolean", hint: "If using the YouTube shortcode, enable this option to append the lite-youtube script." } + - { label: "Body", name: "body", widget: "markdown" } + - label: "Page" + name: "page" + create: false + files: + {% for page in collections.page %} + - label: "{{ page.data.title }}" + name: "{{ page.fileSlug }}" + file: "{{ page.inputPath | replace("./", "") }}" + fields: + - { label: "Title", name: "title", widget: "string" } + - { label: "Permalink", name: "permalink", widget: "string" } + - { label: "Layout", name: "layout", widget: "hidden", default: "layouts/base" } + - { label: "Body", name: "body", widget: "markdown" } + {% endfor %} + - name: "book" + label: "Book" + folder: "src/catalogue/books" + create: true + fields: + - { label: "Title", name: "title", widget: "string" } + - { label: "Subtitle", name: "subtitle", widget: "string" } + - { label: "Author", name: "author", widget: "string" } + - { label: "Rating", name: "rating", widget: "number", min: 1, max: 5 } + - { label: "Image", name: "image", widget: "string", hint: "A CDN URL."} + - { label: "Tags", name: "tags", widget: "list" } + - { label: "Body", name: "body", widget: "markdown" } + - name: "game" + label: "Game" + folder: "src/catalogue/games" + create: true + fields: + - { label: "Title", name: "title", widget: "string" } + - { label: "Subtitle", name: "subtitle", widget: "string" } + - { label: "Year", name: "year", widget: "string" } + - { label: "Rating", name: "rating", widget: "number", min: 1, max: 5 } + - { label: "Image", name: "image", widget: "string", hint: "A CDN URL."} + - { label: "Tags", name: "tags", widget: "list" } + - { label: "Body", name: "body", widget: "markdown" } + - name: "comic" + label: "Comic" + folder: "src/catalogue/comics" + create: true + fields: + - { label: "Title", name: "title", widget: "string" } + - { label: "Publisher", name: "publisher", widget: "string" } + - { label: "Author", name: "author", widget: "string" } + - { label: "Year", name: "year", widget: "string" } + - { label: "Rating", name: "rating", widget: "number", min: 1, max: 5 } + - { label: "Image", name: "image", widget: "string", hint: "A CDN URL."} + - { label: "Tags", name: "tags", widget: "list" } + - { label: "Body", name: "body", widget: "markdown" } + - name: "podcast" + label: "Podcast" + folder: "src/catalogue/podcasts" + create: true + fields: + - { label: "Title", name: "title", widget: "string" } + - { label: "URL", name: "url", widget: "string", hint: "A URL for someone to listen to the podcast." } + - { label: "Rating", name: "rating", widget: "number", min: 1, max: 5 } + - { label: "Image", name: "image", widget: "string", hint: "A CDN URL."} + - { label: "Tags", name: "tags", widget: "list" } + - { label: "Body", name: "body", widget: "markdown" } diff --git a/src/admin/index.html b/src/admin/index.html new file mode 100644 index 0000000..41ba161 --- /dev/null +++ b/src/admin/index.html @@ -0,0 +1,17 @@ +--- +permalink: admin/index.html +--- + + + + + + + + Content Manager + + + + + + diff --git a/src/colophon.md b/src/colophon.md index c1857f4..75d4a78 100644 --- a/src/colophon.md +++ b/src/colophon.md @@ -2,6 +2,7 @@ layout: "layouts/base" permalink: /colophon/index.html title: Colophon +tags: ["page"] --- # Colophon diff --git a/src/css-utils/font-family.js b/src/css-utils/font-family.js index df1f247..c705ad7 100644 --- a/src/css-utils/font-family.js +++ b/src/css-utils/font-family.js @@ -1,8 +1,6 @@ -const path = require("path").posix; +const { getFontUrl } = require("../utils/fonts"); const fonts = require("../../config/design-tokens/fonts.json"); -const getFontUrl = (src) => path.join("/assets/fonts", src); - const fontsToCss = (fonts) => { return Object.entries(fonts).reduce((css, [, fontProperties]) => { const family = fontProperties.family; diff --git a/src/links.md b/src/links.md index 395240a..016074d 100644 --- a/src/links.md +++ b/src/links.md @@ -2,6 +2,7 @@ layout: "layouts/base" permalink: /links/index.html title: Links +tags: ["page"] --- # Find me online diff --git a/src/uses.md b/src/uses.md index ea0bc4d..a250e3e 100644 --- a/src/uses.md +++ b/src/uses.md @@ -2,6 +2,7 @@ layout: "layouts/base" permalink: /uses/index.html title: /uses +tags: ["page"] --- # Uses diff --git a/src/utils/fonts.js b/src/utils/fonts.js new file mode 100644 index 0000000..c556851 --- /dev/null +++ b/src/utils/fonts.js @@ -0,0 +1,7 @@ +const path = require("path"); + +const getFontUrl = (src) => path.join("/assets/fonts", src); + +module.exports = { + getFontUrl, +};