Skip to content
heathduttonPublic

About

Github repo/org/user logo redirection

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

Repository files navigation

ghlogo

A Cloudflare Worker that redirects to the og:image of any GitHub repository, organization, or user.

Usage

https://ghlogo.heathdutton.workers.dev/{owner}
https://ghlogo.heathdutton.workers.dev/{owner}/{repo}

Examples

URL Redirects to
/microsoft Microsoft's org avatar
/microsoft/vscode VS Code repo's social preview
/torvalds Linus Torvalds' avatar
/torvalds/linux Linux repo's social preview

In Markdown

![Repo Logo](https://ghlogo.heathdutton.workers.dev/owner/repo)

In HTML

<img src="https://ghlogo.heathdutton.workers.dev/owner/repo" alt="Repo Logo">

Aspect Ratio

Social previews come back 2:1, which reads as a letterbox next to squarer thumbnails. Add ?ratio= to pad one out:

https://ghlogo.heathdutton.workers.dev/owner/repo?ratio=3:2
https://ghlogo.heathdutton.workers.dev/owner/repo?ratio=4:3

Padding splits evenly between top and bottom, and each half is filled by stretching the image's own edge row. A dark card gets dark bars, a light one gets light. Original pixels are untouched.

PNG only. Indexed color, interlacing, and bit depths other than 8 fall back to the plain redirect, as does any non-PNG.

How It Works

  1. Fetches the GitHub page for the given path
  2. Extracts the <meta property="og:image"> URL
  3. Returns a 302 (temporary) redirect to that image - temporary because the og:image URL changes when owners update their social preview
  4. Caches the redirect in memory for 1 hour

With ?ratio=, step 3 changes: the worker fetches the PNG itself, pads it, and returns the bytes rather than redirecting.

The in-memory cache persists for the lifetime of the worker isolate, reducing latency for repeated requests.

Deploy Your Own

# Clone
git clone https://github.com/heathdutton/ghlogo.git
cd ghlogo

# Install
npm install

# Test locally
npm run dev

# Deploy (requires wrangler auth)
npm run deploy

Update the name in wrangler.toml to use your own subdomain.

License

MIT

About

Github repo/org/user logo redirection

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages