UNPKG

@signalwire/docusaurus-plugin-llms-txt

Version:

Generate Markdown versions of Docusaurus HTML pages and an llms.txt index file

24 lines (23 loc) 746 B
import { select } from 'hast-util-select'; import { toString } from 'hast-util-to-string'; /** * Extract text content from HTML elements by selector * @internal */ export function selectText(tree, selector) { const element = select(selector, tree); // select() returns Element | null, toString() accepts any Node return element ? toString(element).trim() : ''; } /** * Extract the content attribute from a meta tag * @internal */ export function selectMetaContent(tree, selector) { const element = select(selector, tree); // Safely check if element is Element with properties if (element?.type === 'element' && element.properties?.content) { return String(element.properties.content); } return ''; }