feat: enhance medialib image handling and add asset URL resolution

- Implemented `resolveApiAssetUrl` function to normalize asset URLs based on API base.
- Updated `MedialibImage` component to utilize new asset URL resolution and added support for alt text and class properties.
- Enhanced image loading behavior with improved width measurement and focal point handling.
- Added placeholder image handling and improved accessibility with alt text.
- Introduced new test script for auditing broken links in skill documentation.
- Expanded seeded test content to include medialib entries and updated related tests for pagebuilder previews.
- Improved global setup and teardown logging for clarity on seeded content management.
This commit is contained in:
2026-05-17 00:52:41 +00:00
parent 958b45272d
commit 4020ad62c5
44 changed files with 4276 additions and 867 deletions
+29
View File
@@ -1,3 +1,32 @@
import { get } from "svelte/store"
import { apiBaseURL } from "../config"
import { apiBaseOverride } from "./store"
function isAbsoluteUrl(url: string | undefined): boolean {
return !!url && (/^(?:https?:)?\/\//.test(url) || url.startsWith("data:") || url.startsWith("blob:"))
}
function normalizeBase(base: string | null | undefined): string | null {
return base ? base.replace(/\/+$/, "") + "/" : null
}
export function resolveApiAssetUrl(
url: string | null | undefined,
apiBase: string | null | undefined = get(apiBaseOverride) || apiBaseURL
): string | null | undefined {
if (!url || isAbsoluteUrl(url) || !url.startsWith("/assets/")) {
return url
}
const normalizedApiBase = normalizeBase(apiBase)
if (!normalizedApiBase) {
return url
}
return normalizedApiBase + "_/assets/" + url.replace(/^\/+/, "")
}
export function debounce<T extends (...args: never[]) => void>(
func: T,
wait: number