diff --git a/.changeset/twelve-cows-hear.md b/.changeset/twelve-cows-hear.md new file mode 100644 index 000000000000..48caf8dd32bb --- /dev/null +++ b/.changeset/twelve-cows-hear.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': minor +--- + +feat: add `%sveltekit.version%` to `app.html` diff --git a/documentation/docs/10-getting-started/30-project-structure.md b/documentation/docs/10-getting-started/30-project-structure.md index f12af5695942..665a96a0497b 100644 --- a/documentation/docs/10-getting-started/30-project-structure.md +++ b/documentation/docs/10-getting-started/30-project-structure.md @@ -52,6 +52,7 @@ The `src` directory contains the meat of your project. Everything except `src/ro - `error.html` is the page that is rendered when everything else fails. It can contain the following placeholders: - `%sveltekit.status%` — the HTTP status - `%sveltekit.error.message%` — the error message + - `%sveltekit.version%` — the deployment version, which can be specified with the [`version`](configuration#version) configuration - `hooks.client.js` contains your client [hooks](hooks) - `hooks.server.js` contains your server [hooks](hooks) - `service-worker.js` contains your [service worker](service-workers) diff --git a/packages/kit/src/core/sync/write_server.js b/packages/kit/src/core/sync/write_server.js index 639b8506f340..9abf9bae7b88 100644 --- a/packages/kit/src/core/sync/write_server.js +++ b/packages/kit/src/core/sync/write_server.js @@ -7,6 +7,7 @@ import { load_error_page, load_template } from '../config/index.js'; import { runtime_directory } from '../utils.js'; import { isSvelte5Plus, write_if_changed } from './utils.js'; import colors from 'kleur'; +import { escape_html } from '../../utils/escape.js'; /** * @param {{ @@ -54,6 +55,7 @@ export const options = { .replace('%sveltekit.body%', '" + body + "') .replace(/%sveltekit\.assets%/g, '" + assets + "') .replace(/%sveltekit\.nonce%/g, '" + nonce + "') + .replace(/%sveltekit\.version%/g, escape_html(config.kit.version.name)) .replace( /%sveltekit\.env\.([^%]+)%/g, (_match, capture) => `" + (env[${s(capture)}] ?? "") + "`