running-tools

A collection of tools for runners and their coaches
git clone https://git.ashermorgan.net/running-tools/
Log | Files | Refs | README

commit a6cfcf50c08df87178dec599223897f12d050885
parent 8bcd4be3ac28f2a7df8f3413b52a087a101755aa
Author: Asher Morgan <59518073+ashermorgan@users.noreply.github.com>
Date:   Sun, 24 Aug 2025 18:42:40 -0700

Generate changelog page content at build-time

Diffstat:
Mpackage-lock.json | 9++++++++-
Mpackage.json | 2+-
Msrc/views/ChangeLog.vue | 10++--------
Mtsconfig.app.json | 2+-
Avite-env.d.ts | 1+
Dvite.config.js | 70----------------------------------------------------------------------
Avite.config.ts | 80+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 93 insertions(+), 81 deletions(-)

diff --git a/package-lock.json b/package-lock.json @@ -9,7 +9,6 @@ "version": "1.4.1", "dependencies": { "feather-icons": "^4.29.2", - "markdown-it": "^14.1.0", "vue": "^3.5.17", "vue-feather": "^2.0.0", "vue-router": "^4.3.2" @@ -28,6 +27,7 @@ "eslint-plugin-playwright": "^2.2.0", "eslint-plugin-vue": "^10.2.0", "jsdom": "^26.1.0", + "markdown-it": "^14.1.0", "npm-run-all2": "^8.0.4", "pwa-asset-generator": "^8.0.5", "typescript": "^5.8.3", @@ -3836,6 +3836,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, "license": "Python-2.0" }, "node_modules/array-buffer-byte-length": { @@ -7303,6 +7304,7 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", + "dev": true, "license": "MIT", "dependencies": { "uc.micro": "^2.0.0" @@ -7400,6 +7402,7 @@ "version": "14.1.0", "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", + "dev": true, "license": "MIT", "dependencies": { "argparse": "^2.0.1", @@ -7417,6 +7420,7 @@ "version": "4.5.0", "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "dev": true, "license": "BSD-2-Clause", "engines": { "node": ">=0.12" @@ -7446,6 +7450,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", + "dev": true, "license": "MIT" }, "node_modules/memorystream": { @@ -8265,6 +8270,7 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -9800,6 +9806,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", + "dev": true, "license": "MIT" }, "node_modules/unbox-primitive": { diff --git a/package.json b/package.json @@ -20,7 +20,6 @@ }, "dependencies": { "feather-icons": "^4.29.2", - "markdown-it": "^14.1.0", "vue": "^3.5.17", "vue-feather": "^2.0.0", "vue-router": "^4.3.2" @@ -39,6 +38,7 @@ "eslint-plugin-playwright": "^2.2.0", "eslint-plugin-vue": "^10.2.0", "jsdom": "^26.1.0", + "markdown-it": "^14.1.0", "npm-run-all2": "^8.0.4", "pwa-asset-generator": "^8.0.5", "typescript": "^5.8.3", diff --git a/src/views/ChangeLog.vue b/src/views/ChangeLog.vue @@ -1,15 +1,9 @@ <template> - <div class="text" v-html="changelog_html"/> + <div class="text" v-html="content"/> </template> <script setup lang="ts"> -import markdownit from 'markdown-it' - -import changelog_md from '/CHANGELOG.md?raw' - -const changelog_html: string = markdownit({ - typographer: true, // needed to convert '--' to en-dash -}).render(changelog_md.slice(changelog_md.indexOf('\n') + 1)); // render without h1 on first line +const content: string = __CHANGELOG_HTML__; </script> <style scoped> diff --git a/tsconfig.app.json b/tsconfig.app.json @@ -1,6 +1,6 @@ { "extends": "@vue/tsconfig/tsconfig.dom.json", - "include": ["src/**/*"], + "include": ["vite-env.d.ts", "src/**/*"], "compilerOptions": { "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", "resolveJsonModule": true, diff --git a/vite-env.d.ts b/vite-env.d.ts @@ -0,0 +1 @@ +declare const __CHANGELOG_HTML__: string diff --git a/vite.config.js b/vite.config.js @@ -1,70 +0,0 @@ -import { fileURLToPath, URL } from 'node:url'; -import { resolve } from 'path'; -import { defineConfig } from 'vite'; -import { VitePWA } from 'vite-plugin-pwa'; -import vue from '@vitejs/plugin-vue'; - -import { description } from './package.json'; - -// https://vitejs.dev/config/ -export default defineConfig({ - build: { - rollupOptions: { - input: { - index: resolve(__dirname, 'index.html'), - not_found: resolve(__dirname, '404.html'), - }, - }, - }, - plugins: [ - vue(), - VitePWA({ - injectRegister: 'inline', - manifest: { - name: 'Running Tools', - short_name: 'Running Tools', - description: description, - theme_color: '#ff8000', - background_color: '#ff8000', - icons: [ - { - "src": "./img/icons/android-chrome-192x192.png", - "sizes": "192x192", - "type": "image/png", - }, - { - "src": "./img/icons/android-chrome-512x512.png", - "sizes": "512x512", - "type": "image/png", - }, - { - "src": "./img/icons/android-chrome-maskable-192x192.png", - "sizes": "192x192", - "type": "image/png", - "purpose": "maskable", - }, - { - "src": "./img/icons/android-chrome-maskable-512x512.png", - "sizes": "512x512", - "type": "image/png", - "purpose": "maskable", - }, - ], - }, - }), - ], - resolve: { - alias: { - '@': fileURLToPath(new URL('./src', import.meta.url)), - }, - }, - base: process.env.BASE_URL || '/', - define: { - 'import.meta.env.VITE_DESCRIPTION': `"${description}"`, - 'import.meta.env.VITE_DOMAIN': process.env.DOMAIN ? `"https://${process.env.DOMAIN}"` : '""', - }, - test: { - environment: 'jsdom', - include: ['tests/unit/**/*.{test,spec}.?(c|m)[jt]s?(x)'], - }, -}); diff --git a/vite.config.ts b/vite.config.ts @@ -0,0 +1,80 @@ +import { fileURLToPath, URL } from 'node:url'; +import { resolve } from 'path'; +import { defineConfig } from 'vite'; +import { VitePWA } from 'vite-plugin-pwa'; +import fs from 'fs'; +import markdownit from 'markdown-it' +import vue from '@vitejs/plugin-vue'; + +import { description } from './package.json'; + +// Convert changelog from markdown to HTML +const changelog_md: string = fs.readFileSync('./CHANGELOG.md', 'utf-8'); +const changelog_html: string = markdownit({ + typographer: true, // needed to convert '--' to en-dash +}).render(changelog_md.slice(changelog_md.indexOf('\n') + 1)) // render without h1 on first line + .replace(/\n/g, ' '); // join lines together + +// https://vitejs.dev/config/ +export default defineConfig({ + build: { + rollupOptions: { + input: { + index: resolve(__dirname, 'index.html'), + not_found: resolve(__dirname, '404.html'), + }, + }, + }, + plugins: [ + vue(), + VitePWA({ + injectRegister: 'inline', + manifest: { + name: 'Running Tools', + short_name: 'Running Tools', + description: description, + theme_color: '#ff8000', + background_color: '#ff8000', + icons: [ + { + "src": "./img/icons/android-chrome-192x192.png", + "sizes": "192x192", + "type": "image/png", + }, + { + "src": "./img/icons/android-chrome-512x512.png", + "sizes": "512x512", + "type": "image/png", + }, + { + "src": "./img/icons/android-chrome-maskable-192x192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable", + }, + { + "src": "./img/icons/android-chrome-maskable-512x512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable", + }, + ], + }, + }), + ], + resolve: { + alias: { + '@': fileURLToPath(new URL('./src', import.meta.url)), + }, + }, + base: process.env.BASE_URL || '/', + define: { + 'import.meta.env.VITE_DESCRIPTION': `"${description}"`, + 'import.meta.env.VITE_DOMAIN': process.env.DOMAIN ? `"https://${process.env.DOMAIN}"` : '""', + '__CHANGELOG_HTML__': JSON.stringify(changelog_html), + }, + test: { + environment: 'jsdom', + include: ['tests/unit/**/*.{test,spec}.?(c|m)[jt]s?(x)'], + }, +});