Skip to content

Commit

Permalink
feat: add open graph image alt type (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
amyjchen committed Dec 5, 2022
1 parent cd3f189 commit 23211f2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -113,6 +113,7 @@ type Metadata = {
type: string
width: number
height: number
alt?: string
}[]
url?: string
audio?: {
Expand Down
4 changes: 4 additions & 0 deletions src/schema.ts
Expand Up @@ -167,6 +167,10 @@ export const schema = new Map([
"og:image:height",
{ entry: "open_graph", name: "height", parent: "images", type: "number" },
],
[
"og:image:alt",
{ entry: "open_graph", name: "alt", parent: "images", type: "string" },
],
[
"og:image:type",
{ entry: "open_graph", name: "type", parent: "images", type: "string" },
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Expand Up @@ -85,6 +85,7 @@ export type Metadata = {
type: string;
width: number;
height: number;
alt?: string;
}[];
url?: string;
audio?: {
Expand Down
2 changes: 2 additions & 0 deletions test/open_graph/images.html
Expand Up @@ -5,6 +5,7 @@
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="1200">
<meta property="og:image:alt" content="The Github logo.">
<meta property="og:image" content="https://assets-cdn.github.com/images/modules/open_graph/github-mark.png">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="1200">
Expand All @@ -13,6 +14,7 @@
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="620">
<meta property="og:image:alt" content="The Github octocat.">
</head>
<body></body>
</html>
2 changes: 2 additions & 0 deletions test/open_graph/test.ts
Expand Up @@ -49,6 +49,7 @@ test("should build images[]", async () => {
type: "image/png",
width: 1200,
height: 1200,
alt: "The Github logo.",
},
{
url: "https://assets-cdn.github.com/images/modules/open_graph/github-mark.png",
Expand All @@ -61,6 +62,7 @@ test("should build images[]", async () => {
type: "image/png",
width: 1200,
height: 620,
alt: "The Github octocat.",
},
],
};
Expand Down

0 comments on commit 23211f2

Please sign in to comment.