Set absolute URL for og:image meta tags by parcel ver >= 2.0.0.
Inspired by lukechilds/parcel-plugin-ogimage
$ npm install -D parcel-transformer-ogimage
Create .parcelrc
file and paste:
{
"extends": "@parcel/config-default",
"transformers": {"*.html":["...","parcel-transformer-ogimage"]}
}
Just install this package as a development dependency. Parcel will automatically call it when building your application.
You must have both og:image
and og:url
meta tags:
<meta property="og:image" content="card.png">
<meta property="og:url" content="https://example.com">
Parcel will generate that into something like this:
<meta property="og:image" content="/card.9190ce93.png">
<meta property="og:url" content="https://example.com">
Works also for twitter:image
.
<meta name="twitter:image" content="/card.9190ce93.png">
parcel-plugin-ogimage
will then update the og:image
with an absolute URL:
<meta property="og:image" content="https://example.com/card.9190ce93.png">
<meta property="og:url" content="https://example.com">
<meta name="twitter:image" content="https://example.com/card.9190ce93.png">
MIT