{"id":20206502,"url":"https://github.com/useflyyer/flyyer-opengraph-properties","last_synced_at":"2026-06-08T11:01:41.604Z","repository":{"id":38425862,"uuid":"363530140","full_name":"useflyyer/flyyer-opengraph-properties","owner":"useflyyer","description":"Convert meta-tags into an object with accessor. Supports single and multiple tags via pluralization.","archived":false,"fork":false,"pushed_at":"2023-01-07T07:09:51.000Z","size":899,"stargazers_count":2,"open_issues_count":7,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-01T12:35:18.344Z","etag":null,"topics":["flyyer","html","meta-tags","og-image","open-graph","seo","twitter-cards","typescript"],"latest_commit_sha":null,"homepage":"https://flyyer.io","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/useflyyer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-01T23:49:29.000Z","updated_at":"2023-12-14T14:26:06.000Z","dependencies_parsed_at":"2023-02-06T14:31:57.534Z","dependency_job_id":null,"html_url":"https://github.com/useflyyer/flyyer-opengraph-properties","commit_stats":null,"previous_names":["flayyer/flayyer-opengraph-properties"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/useflyyer/flyyer-opengraph-properties","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/useflyyer%2Fflyyer-opengraph-properties","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/useflyyer%2Fflyyer-opengraph-properties/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/useflyyer%2Fflyyer-opengraph-properties/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/useflyyer%2Fflyyer-opengraph-properties/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/useflyyer","download_url":"https://codeload.github.com/useflyyer/flyyer-opengraph-properties/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/useflyyer%2Fflyyer-opengraph-properties/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34059157,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flyyer","html","meta-tags","og-image","open-graph","seo","twitter-cards","typescript"],"created_at":"2024-11-14T05:24:30.016Z","updated_at":"2026-06-08T11:01:41.586Z","avatar_url":"https://github.com/useflyyer.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @flyyer/opengraph-properties\n\nConvert meta-tags into a object with accessor. Supports single and multiple tags via [pluralization](https://github.com/plurals/pluralize).\n\n```sh\nyarn add @flyyer/opengraph-properties\n```\n\n## Usage\n\n```ts\nimport { parseMetaTags, MetaTag, extractString, extractNumber } from \"@flyyer/opengraph-properties\";\nimport * as cheerio from \"cheerio\";\n\nconst raw = `\n  \u003cmeta property=\"og:image\" content=\"https://example.com/rock.jpg\" /\u003e\n  \u003cmeta property=\"og:image:width\" content=\"300\" /\u003e\n  \u003cmeta property=\"og:image:height\" content=\"300\" /\u003e\n  \u003cmeta property=\"og:image\" content=\"https://example.com/rock2.jpg\" /\u003e\n  \u003cmeta property=\"og:image\" content=\"https://example.com/rock3.jpg\" /\u003e\n  \u003cmeta property=\"og:image:height\" content=\"1000\" /\u003e\n`;\n\n// means there are 3 images on this page, the first image is 300x300, the middle one has unspecified dimensions, and the last one is 1000px tall.\n\nconst $ = cheerio.load(raw);\nconst metatags: MetaTag[] = Array.from($(\"meta\"), (meta) =\u003e meta.attribs);\nconst parsed = parseMetaTags(metatags, {\n  // Convert `name` or `property` key to lowercase and trim whitespace.\n  normalizeKey: true,\n  // Trim white space from `content`.\n  normalizeValue: true,\n});\n\n// First appearance take precedence.\nextractString(parsed.og[\"image\"]) === \"https://example.com/rock.jpg\";\nextractNumber(parsed.og[\"image\"][\"width\"]) === 300;\nextractNumber(parsed.og[\"image\"][\"height\"]) === 300;\n\n// A pluralized key is always created to handle multiple appearances.\nextractString(parsed.og[\"images\"][0]) === \"https://example.com/rock.jpg\";\nextractNumber(parsed.og[\"images\"][0][\"width\"]) === 300;\nextractNumber(parsed.og[\"images\"][0][\"height\"]) === 300;\nextractString(parsed.og[\"images\"][1]) === \"https://example.com/rock2.jpg\";\nextractString(parsed.og[\"images\"][2]) === \"https://example.com/rock3.jpg\";\nextractNumber(parsed.og[\"images\"][2][\"height\"]) === 1000;\n```\n\nUndeclared properties are `undefined`.\n\n```ts\nextractNumber(parsed.og[\"images\"][2][\"width\"]) === undefined\n```\n\nAlso a property accessor can be used as second argument.\n\n```ts\nextractNumber(parsed.og, \"images.2.height\") === 1000;\nextractNumber(parsed.og, [\"images\", 2, \"height\"]) === 1000;\n```\n\n### LiquidJS\n\nCan be used with [liquidjs](https://github.com/harttle/liquidjs).\n\n```ts\nimport { parseMetaTags, MetaTag, extractString, extractNumber } from \"@flyyer/opengraph-properties\";\nimport { Liquid } from \"liquidjs\";\n\nconst metatags: MetaTag[] = [\n  {\n    property: \"og:audio\",\n    content: \"https://example.com/bond/theme.mp3\",\n  },\n  {\n    property: \"og:locale\",\n    content: \"en_GB\",\n  },\n  {\n    property: \"og:locale:alternate\",\n    content: \"fr_FR\",\n  },\n  {\n    property: \"og:locale:alternate\",\n    content: \"es_ES\",\n  },\n];\n\nconst parsed = parseMetaTags(metatags);\nconst engine = new Liquid({ globals: parsed });\n\nconst print = engine.parseAndRenderSync(`\n  Listening to {{ og.audio }} in {{ og.locale }}\n\n  Available locales:\n  {% for locale in og.locale.alternates %}\n    Language: {{ locale }}\n  {% endfor %}\n`);\nconsole.log(print);\n```\n\nWill print:\n\n```txt\nListening to https://example.com/bond/theme.mp3 in en_GB\n\nAvailable locales:\nLanguage: fr_FR\nLanguage: es_ES\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuseflyyer%2Fflyyer-opengraph-properties","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuseflyyer%2Fflyyer-opengraph-properties","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuseflyyer%2Fflyyer-opengraph-properties/lists"}