简体   繁体   中英

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 anXMLHttpRequest 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?

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;-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM