feat: make og images an emitter to properly await image generation (#1826)

* checkpoint

* make emitters async generators

* fix

* custom font spec

* replace spinner, use disk cache for fonts

* use readline instead

* make og images look nice
This commit is contained in:
Jacky Zhao
2025-03-13 10:27:46 -07:00
committed by GitHub
parent c005fe4408
commit d9159e0ac9
30 changed files with 967 additions and 821 deletions

View File

@ -36,7 +36,7 @@ export type RelativeURL = SlugLike<"relative">
export function isRelativeURL(s: string): s is RelativeURL {
const validStart = /^\.{1,2}/.test(s)
const validEnding = !endsWith(s, "index")
return validStart && validEnding && ![".md", ".html"].includes(_getFileExtension(s) ?? "")
return validStart && validEnding && ![".md", ".html"].includes(getFileExtension(s) ?? "")
}
export function getFullSlug(window: Window): FullSlug {
@ -61,7 +61,7 @@ function sluggify(s: string): string {
export function slugifyFilePath(fp: FilePath, excludeExt?: boolean): FullSlug {
fp = stripSlashes(fp) as FilePath
let ext = _getFileExtension(fp)
let ext = getFileExtension(fp)
const withoutFileExt = fp.replace(new RegExp(ext + "$"), "")
if (excludeExt || [".md", ".html", undefined].includes(ext)) {
ext = ""
@ -272,10 +272,10 @@ function containsForbiddenCharacters(s: string): boolean {
}
function _hasFileExtension(s: string): boolean {
return _getFileExtension(s) !== undefined
return getFileExtension(s) !== undefined
}
function _getFileExtension(s: string): string | undefined {
export function getFileExtension(s: string): string | undefined {
return s.match(/\.[A-Za-z0-9]+$/)?.[0]
}