tickle/modules/utils/getFirstTitleContent.mjs
2023-05-09 04:00:53 +02:00

13 lines
378 B
JavaScript

/**
* Returns the first title content in the document, if there is one.
* @param {Node} content
* @returns
*/
export const getFirstTitleContent = (content = document) => {
/** @type {HTMLHeadElement} */
const firstTitleElement = content.querySelector("h1");
return firstTitleElement ? firstTitleElement.textContent || "" : "";
};
export default getFirstTitleContent;