Skip to content

Commit

Permalink
Only support name for twitter
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick91 committed Mar 13, 2024
1 parent 6fb49e7 commit 4fad121
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/astro-meta-tags/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
18 changes: 8 additions & 10 deletions packages/astro-meta-tags/src/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4fad121

Please sign in to comment.