Skip to content

Commit

Permalink
etc
Browse files Browse the repository at this point in the history
  • Loading branch information
elringus committed Dec 6, 2023
1 parent c9949a7 commit 31de7c2
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions docs/.vitepress/imgit/plugin/youtube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ export default function (): Plugin {
};
};

/** Whether specified url is a valid YouTube video link. */
function isYouTube(url: string): boolean {
return url.includes("youtube.com/watch?v=");
}

/** Given valid url to a YouTube video, extracts video ID. */
function getYouTubeId(url: string): string {
return new URL(url).searchParams.get("v")!;
}

async function resolve(asset: ResolvedAsset): Promise<boolean> {
if (!isYouTube(asset.syntax.url)) return false;
const id = getYouTubeId(asset.syntax.url);
Expand All @@ -53,6 +43,16 @@ function build(asset: BuiltAsset): boolean {
return true;
}

/** Whether specified url is a valid YouTube video link. */
function isYouTube(url: string): boolean {
return url.includes("youtube.com/watch?v=");
}

/** Given valid url to a YouTube video, extracts video ID. */
function getYouTubeId(url: string): string {
return new URL(url).searchParams.get("v")!;
}

async function resolveThumbnailUrl(id: string): Promise<string> {
if ((<YouTubeCache>cache).youtube.hasOwnProperty(id))
return (<YouTubeCache>cache).youtube[id];
Expand Down

0 comments on commit 31de7c2

Please sign in to comment.