Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openGraph new option: path #43

Open
fcisio opened this issue Apr 6, 2021 · 1 comment
Open

openGraph new option: path #43

fcisio opened this issue Apr 6, 2021 · 1 comment

Comments

@fcisio
Copy link

fcisio commented Apr 6, 2021

Description

Hi, when adding images to openGraph, right now we can use the url option.

It would be nice to allow for relative paths with a path option.

images: [
  {
    path: 'src/images/og-image-1.jpg',
    width: 800,
    height: 600,
    alt: 'Og Image Alt',
  },
  {
    path: path.resolve(__dirname, 'src/images/og-image-2.jpg'),
    width: 800,
    height: 600,
    alt: 'Og Image Alt 2',
  },
],

I know that it's currently possible by adding the domain used with the project. But manually adding the domain doesn't work well with multiple environments (staging.domain.com, domain.com, localhost, ...).

@fcisio
Copy link
Author

fcisio commented Apr 6, 2021

I do have a workaround for this if anyone is interested:

// env.development
GATBSY_DOMAIN="http://localhost:8000"

// gatsby-config.js
require('dotenv').config({
  path: `.env.development`,
})

...

{
  url: `${process.env.GATBSY_DOMAIN}/images/socials.png`
}

Then set the env variable to the right domain when you deploy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant