Scott Anderson
Scott Anderson

Reputation: 693

Get social media image from Github repository

I am currently trying to build a Jekyll site with github-pages, and I would like to gather opengraph headers for each repository I own to create 'rich previews' of each repository.

I am able to add a 'Social Preview' image to Github, but this doesn't seem to be exposed to the API. I also tried creating an XMLHttpRequest but I get:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://github.com/user/repo. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing)

Finally I do wonder if my plugin github-metadata already has the image, but I don't know how to read the generated data

Does anyone know if there is a way which would be feasible in a github-pages environment by which I could get this information into my site?

Upvotes: 0

Views: 630

Answers (1)

David Jacquel
David Jacquel

Reputation: 52829

You can find all exposed metadatas here.

There is no specific image that can be set for each repository. The only image available is owner's avatar : {{ site.github.owner_gravatar_url }}.

And you can generate you opengraph headers with help of jekyll-seo-tag at build time. No more need to use javascript magic ;-)

Upvotes: 1

Related Questions