From 5afe9ee4cdb7278f1e8b039df15ac9e2ccd49b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Brunet?= Date: Wed, 19 May 2021 23:59:58 +0200 Subject: [PATCH] Make rest of the content editable from CMS --- README.md | 2 +- src/_data/nav.json | 22 +++++++++++--------- src/_includes/components/navigation.njk | 2 +- src/_includes/layouts/home.njk | 2 +- src/admin/config.yml | 27 ++++++++++++++++++++++++- src/index.md | 1 + src/scss/components/_recipe.scss | 1 + 7 files changed, 43 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 904f42a..9513fe1 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ The kit includes a powerful live search system offering a UX on-par with third-p ### 🧰 Lightweight & easily extendable -Easily customise the theme color and other site attributes using the global data files, or dive into the code and change anything easily. The CSS is authored using [Sass](https://sass-lang.com/) and following the [BEM](https://en.bem.info/) naming convention. JavaScript is added where needed using [Alpine](https://github.com/alpinejs/alpine) and following a component-based approach. Images are processed and optimised at build-time using the [Eleventy image plugin](https://www.11ty.dev/docs/plugins/image/). Apart from Alpine, there are no run-time dependencies, making the site both extremely lightweight and easy to pick up and modify. +Easily customise the theme color and other site attributes using the global data files, or dive into the code and change anything. The CSS is authored using [Sass](https://sass-lang.com/) and following the [BEM](https://en.bem.info/) naming convention. JavaScript is added where needed using [Alpine](https://github.com/alpinejs/alpine) and following a component-based approach. Images are processed and optimised at build-time using the [Eleventy image plugin](https://www.11ty.dev/docs/plugins/image/). Apart from Alpine, there are no run-time dependencies, making the site both extremely lightweight and easy to pick up and modify. ## Run the site locally diff --git a/src/_data/nav.json b/src/_data/nav.json index a2bf8b2..b228017 100644 --- a/src/_data/nav.json +++ b/src/_data/nav.json @@ -1,10 +1,12 @@ -[ - { - "text": "All recipes", - "url": "/recipes/" - }, - { - "text": "About", - "url": "/about/" - } -] \ No newline at end of file +{ + "items": [ + { + "text": "All recipes", + "url": "/recipes/" + }, + { + "text": "About", + "url": "/about/" + } + ] +} \ No newline at end of file diff --git a/src/_includes/components/navigation.njk b/src/_includes/components/navigation.njk index 5e0ed06..694694a 100644 --- a/src/_includes/components/navigation.njk +++ b/src/_includes/components/navigation.njk @@ -6,7 +6,7 @@ Home - {% for navItem in nav %} + {% for navItem in nav.items %}
  • {{ navItem.text }}
  • diff --git a/src/_includes/layouts/home.njk b/src/_includes/layouts/home.njk index d23b48e..8fd3438 100644 --- a/src/_includes/layouts/home.njk +++ b/src/_includes/layouts/home.njk @@ -7,7 +7,7 @@ bodyClass: c-home {% block content %}
    -

    {{title}} {{ site.author }}

    +

    {{title}}{% if authorInTitle %} {{ site.author }}{% endif %}

    diff --git a/src/admin/config.yml b/src/admin/config.yml index 91c0263..9cd9ae0 100644 --- a/src/admin/config.yml +++ b/src/admin/config.yml @@ -36,15 +36,40 @@ collections: delete: false file: "src/_data/site.json" fields: - - {label: "Site name", name: "name", widget: "string"} + - {label: "Site name", name: "name", widget: "string", hint: "used for SEO"} - {label: "Site meta description", name: "metaDescription", widget: "string", hint: "used for SEO"} - {label: "Author", name: "author", widget: "string"} - {label: "Primary color", name: "primaryColor", widget: "color", hint: "make sure to choose a color that is light enough to display as a background behind dark text"} - {label: "Secondary color", name: "secondaryColor", widget: "color", hint: "used for links and focus styles"} - {label: "Search label", name: "searchLabel", widget: "string"} + - name: "nav" + label: "Navigation" + delete: false + file: "src/_data/nav.json" + fields: + - label: "Items" + name: "items" + widget: "list" + fields: + - {label: "Text", name: "text", widget: "string"} + - {label: "Url", name: "url", widget: "string"} - name: "pages" label: "Pages" files: + - name: "home" + label: "Homepage" + file: "src/index.md" + fields: + - {label: "Title", name: "title", widget: "string"} + - {label: "Add author to title", name: "authorInTitle", widget: "boolean"} + - {label: "Meta title", name: "metaTitle", widget: "string", hint: "used for SEO"} + - {label: "Favourite recipes label", name: "favouriteRecipes", widget: "string"} + - {label: "Random recipe label", name: "randomRecipe", widget: "string"} + - name: "recipes" + label: "All recipes page" + file: "src/recipes.md" + fields: + - {label: "Title", name: "title", widget: "string"} - name: "about" label: "About page" file: "src/about.md" diff --git a/src/index.md b/src/index.md index 5c6cea0..a3db33a 100644 --- a/src/index.md +++ b/src/index.md @@ -1,6 +1,7 @@ --- layout: layouts/home.njk title: This cookbook belongs to +authorInTitle: true metaTitle: Home favouriteRecipes: Some of my favourite recipes randomRecipe: random recipe diff --git a/src/scss/components/_recipe.scss b/src/scss/components/_recipe.scss index 9f72f9b..e91ac8d 100644 --- a/src/scss/components/_recipe.scss +++ b/src/scss/components/_recipe.scss @@ -3,6 +3,7 @@ object-fit: cover; height: 40vh; min-height: 300px; + background-color: var(--color-grey-500); // fallback while image is loading } .c-recipe__title {