From b4a2655d0af533fbaa71e96635255fc574701bbc Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Fri, 12 Jan 2024 12:37:43 -0800 Subject: [PATCH] chore: use app version to populate version query params --- .eleventy.js | 8 +++++++- package.json | 2 +- src/_includes/base.liquid | 6 +++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.eleventy.js b/.eleventy.js index 313d3f00..c0e4a70d 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -23,6 +23,12 @@ import { execSync } from 'child_process' import dotenvFlow from 'dotenv-flow' dotenvFlow.config() +// get app version +import { createRequire } from 'module' + +const require = createRequire(import.meta.url) +const appVersion = require('./package.json').version + /** * @param {import("@11ty/eleventy/src/UserConfig")} eleventyConfig */ @@ -104,7 +110,7 @@ export default async function (eleventyConfig) { // shortcodes eleventyConfig.addShortcode('image', img) - eleventyConfig.addShortcode('assetHash', () => Math.random()) + eleventyConfig.addShortcode('appVersion', () => appVersion) // transforms eleventyConfig.addTransform('html-minify', (content, path) => { diff --git a/package.json b/package.json index 4c128a11..c67caf98 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "4.7.1", + "version": "4.8.0", "description": "The source for my personal site, blog and portfolio. Built using 11ty and hosted on Netlify.", "type": "module", "scripts": { diff --git a/src/_includes/base.liquid b/src/_includes/base.liquid index d88d6cfa..9d09fb8d 100644 --- a/src/_includes/base.liquid +++ b/src/_includes/base.liquid @@ -22,14 +22,14 @@ - + {% capture css %} {% render "../assets/styles/fonts/silka.css" %} {% render "../assets/styles/partials/vars.css" %}