mirror of
https://github.com/zadam/trilium.git
synced 2026-09-14 11:06:04 +05:00
The notes under docs/Release Notes are exported from Trilium, so their images are bare filenames sitting next to the Markdown. That renders in the repository, but the publish step hands the same file to the release body, where GitHub resolves a relative source against the releases URL — so every image would have arrived broken. v0.105.0 is the first note to carry any. The body is now composed by scripts/release-notes-body.mts, which rewrites those sources to raw.githubusercontent.com URLs pinned to refs/tags/<tag>, and fails the job when a referenced image is not in the repository. Pinning to the tag rather than a branch keeps a published body correct if the images later move. The script has no dependencies, so the publish job runs it off its sparse checkout without installing the monorepo. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
54 lines
2.4 KiB
TypeScript
54 lines
2.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { rewriteImageSources } from "./release-notes-body.mjs";
|
|
|
|
const OPTIONS = { repository: "TriliumNext/Trilium", tag: "v0.105.0" };
|
|
const BASE = "https://raw.githubusercontent.com/TriliumNext/Trilium/refs/tags/v0.105.0/docs/Release%20Notes/Release%20Notes";
|
|
|
|
describe("rewriteImageSources", () => {
|
|
it("pins relative sources to the tag, in both the exported and the Markdown form", () => {
|
|
const { body, images } = rewriteImageSources([
|
|
`<figure class="image image_resized" style="width:45.59%;"><img style="aspect-ratio:1509/1329;" src="v0.105.0_image.png" width="1509" height="1329"></figure>`,
|
|
``
|
|
].join("\n"), OPTIONS);
|
|
|
|
expect(body).toBe([
|
|
`<figure class="image image_resized" style="width:45.59%;"><img style="aspect-ratio:1509/1329;" src="${BASE}/v0.105.0_image.png" width="1509" height="1329"></figure>`,
|
|
``
|
|
].join("\n"));
|
|
expect(images).toEqual([
|
|
"docs/Release Notes/Release Notes/v0.105.0_image.png",
|
|
"docs/Release Notes/Release Notes/1_v0.105.0_image.png"
|
|
]);
|
|
});
|
|
|
|
it("leaves sources that are already absolute alone", () => {
|
|
const note = [
|
|
`<img src="https://github.com/user-attachments/assets/25f916f8.png">`,
|
|
`<img src="//example.com/hosted.png">`,
|
|
`<img src="data:image/png;base64,AAAA">`,
|
|
``,
|
|
`[A link](v0.99.5.md) and <a href="v0.99.5.md">another</a>`
|
|
].join("\n");
|
|
|
|
const { body, images } = rewriteImageSources(note, OPTIONS);
|
|
|
|
expect(body).toBe(note);
|
|
expect(images).toEqual([]);
|
|
});
|
|
|
|
it("resolves a source against the release notes folder", () => {
|
|
const { body, images } = rewriteImageSources(
|
|
`<img src="./same.png"><img src="../shared/other.png">`, OPTIONS);
|
|
|
|
expect(body).toBe([
|
|
`<img src="${BASE}/same.png">`,
|
|
`<img src="https://raw.githubusercontent.com/TriliumNext/Trilium/refs/tags/v0.105.0/docs/Release%20Notes/shared/other.png">`
|
|
].join(""));
|
|
expect(images).toEqual([
|
|
"docs/Release Notes/Release Notes/same.png",
|
|
"docs/Release Notes/shared/other.png"
|
|
]);
|
|
});
|
|
});
|