Skip to main content
Glama
LinkExtractor.ts1.02 kB
export function extractImageLinks(content: string): string[] { const imageLinks: string[] = []; const wikiLinkRegex = /!\[\[([^\]]+)\]\]/g; const markdownLinkRegex = /!\[.*?\]\((.*?)\)/g; let match: RegExpExecArray | null; match = wikiLinkRegex.exec(content); while (match !== null) { imageLinks.push(match[1]); match = wikiLinkRegex.exec(content); } match = markdownLinkRegex.exec(content); while (match !== null) { imageLinks.push(match[1]); match = markdownLinkRegex.exec(content); } return imageLinks; } export function extractDocumentLinks(content: string): string[] { const docLinks: string[] = []; const wikiLinkRegex = /(?<!!)\[\[([^\]]+)\]\]/g; let match: RegExpExecArray | null; match = wikiLinkRegex.exec(content); while (match !== null) { // 링크에서 앨리어스(|)나 앵커(#) 부분을 제거하고 순수 파일 이름만 추출합니다. const link = match[1].split(/\||#/)[0]; docLinks.push(link); match = wikiLinkRegex.exec(content); } return docLinks; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sunub/obsidian-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server