diff --git a/packages/astro-meta-tags/package.json b/packages/astro-meta-tags/package.json index 53e5357..cf12bad 100644 --- a/packages/astro-meta-tags/package.json +++ b/packages/astro-meta-tags/package.json @@ -1,6 +1,6 @@ { "name": "astro-meta-tags", - "version": "0.2.1", + "version": "0.2.2", "author": "Patrick Arminio", "repository": "github:patrick91/astro-meta-tags", "license": "MIT", diff --git a/packages/astro-meta-tags/src/toolbar.ts b/packages/astro-meta-tags/src/toolbar.ts index 2909356..9ddfa0f 100644 --- a/packages/astro-meta-tags/src/toolbar.ts +++ b/packages/astro-meta-tags/src/toolbar.ts @@ -10,21 +10,19 @@ const getWindowContent = () => { .querySelector("meta[name='description']") ?.getAttribute("content"); - const getTagTuple = (tag: Element) => - [ - tag.getAttribute("property") || tag.getAttribute("name"), - tag.getAttribute("content"), - ] as [string, string]; + const getTagTuple = (tag: Element, attributeName: string = "property") => + [tag.getAttribute(attributeName), tag.getAttribute("content")] as [ + string, + string + ]; const ogMetaTags = Array.from( document.querySelectorAll("meta[property^='og:']") - ).map(getTagTuple); + ).map((tag) => getTagTuple(tag, "property")); const twitterMetaTags = Array.from( - document.querySelectorAll( - "meta[property^='twitter:'], meta[name^='twitter:']" - ) - ).map(getTagTuple); + document.querySelectorAll("meta[name^='twitter:']") + ).map((tag) => getTagTuple(tag, "name")); const getSingleTagHtml = ([property, content]: [string, string]) => { let contentTag: HTMLElement | Text;