diff --git a/.eleventy.js b/.eleventy.js index b7a1f94..7893656 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -145,6 +145,37 @@ module.exports = async function(eleventyConfig) { return `${picture}`; }); + // image path for meta tags + eleventyConfig.addNunjucksAsyncShortcode("getOGImageUri", async (page, src) => { + if (!src) return "/img/tete-2006.png"; + + let inputFolder = page.inputPath.split("/") + inputFolder.pop() + inputFolder = inputFolder.join("/"); + const imageSrc = inputFolder+"/"+src; + + let urlPath = page.outputPath.split("/") + urlPath.pop() + urlPath.shift() + urlPath = "/" + urlPath.join("/"); + + // TODO: limit to a certain max height 200x200 min 1200×1200 max + let metadata = await Image(imageSrc, { + widths: [1200], + formats: ["webp"], + urlPath: urlPath, + outputDir: `./_site/${page.url}`, + filenameFormat: function (id, src, width, format, options) { + const extension = path.extname(src); + const name = path.basename(src, extension); + return `${name}-og.${format}`; + } + }) + + const data = metadata.webp[0] + // data.url might be /blog/hello-world/xfO_genLg4-600.jpeg + return data.url + }) // Collections eleventyConfig.addCollection("documentation", function (collection) { diff --git a/src/_assets/public/admin/config.yml b/src/_assets/public/admin/config.yml index 6d2fa7c..b1fce37 100644 --- a/src/_assets/public/admin/config.yml +++ b/src/_assets/public/admin/config.yml @@ -9,7 +9,7 @@ backend: name: github repo: aloxe/huwindty # Path to your GitHub repository - branch: ecrire + branch: seo-fields base_url: https://auth.xn--4lj4bfp6d.eu.org # Path to ext auth provider @@ -24,6 +24,8 @@ collections: - name: "documentation" # Used in routes, e.g., /admin/collections/blog label: "Documentation" # Used in the UI folder: "src/pages/documentation" # The path to the folder where the documents are stored + thumbnail: true + columns: [title, date] media_folder: '' # start with a slash public_folder: /documentation create: true # Allow users to create new documents in this collection @@ -49,21 +51,26 @@ collections: - label: "description" name: "description" widget: "string" - picker_utc: false + required: false - label: "tags" name: "tags" widget: "string" - picker_utc: false + required: false - label: "author" name: "author" widget: "string" - picker_utc: false + required: false - label: "date" name: "date" widget: "datetime" default: "{{now}}" format: "YYYY-MM-DD" picker_utc: false + - label: "Featured Image" + name: "thumbnail" + widget: "image" + allow_multiple: false + required: false - name: "examples" # Used in routes, e.g., /admin/collections/blog label: "Examples" # Used in the UI folder: "src/pages/examples" # The path to the folder where the documents are stored diff --git a/src/_layouts/includes/head.njk b/src/_layouts/includes/head.njk index 35d3502..5fbb13c 100644 --- a/src/_layouts/includes/head.njk +++ b/src/_layouts/includes/head.njk @@ -1,5 +1,5 @@ - +{% if meta.author.name %}{% endif %} @@ -9,26 +9,36 @@ {% endif %} -