Skip to content

Instantly share code, notes, and snippets.

View FlakyBlueJay's full-sized avatar

Flaky FlakyBlueJay

View GitHub Profile
@L4Ph
L4Ph / remark-lite-youtube.ts
Last active May 30, 2026 18:52
remark plugin
import { visit } from "unist-util-visit";
import type { Root, Text, HTML, Link, PhrasingContent } from "mdast";
const extractYouTubeVideoID = (url: string): string | undefined => {
try {
const { hostname, pathname, searchParams } = new URL(url);
if (/(^|\.)youtube\.com$/.test(hostname)) {
if (pathname === "/watch") {
return searchParams.get("v") ?? undefined;