Collected.Press API

We serve a read-only transformation of public GitHub repos. It is provided with no warranty.

View GitHub Repo

Fetches the HEAD and redirects to include its SHA.

For example:


Styled GitHub Repo File

/github/{owner}/{repo}@{sha}/{...path}

Renders a file within a GitHub repo.

Markdown (file extension .md)

If the file is Markdown, then it is rendered as HTML. Syntax highlighting is done using highlight.js. This HTML has no <head> or <body>, and is designed for you to provide your own CSS, meta tags, links, and so on.

Images (MIME type image/*)

Images are presented within an HTML page, loading from their corresponding jsdelivr URL.

Other file types

Other file types are wrapped in Markdown fenced code blocks using the file extension as the language. This is then rendered to HTML like any other Markdown.

For example a style.css file will get transformed into:

~~~~~~~~~~~~css
CONTENTS OF style.css
~~~~~~~~~~~~

GitHub Repo Directory

Renders a list of files fetched from jsdelivr.


Unstyled GitHub Repo File

/1/github/{owner}/{repo}@{sha}/{...path}

Renders a file within a GitHub repo without a <head> or any styles. This makes it a good fit for being loaded by an edge worker, where you can prepend your own <head> and styles.


Get Latest GitHub HEAD Ref

/1/github/{owner}/{repo}/refs/HEAD

Get the latest SHA of the default branch, which is usually main.

This is equivalent to running git ls-remote https://github.com/owner/repo --symref HEAD in your shell.

You can use this SHA in any collected.press route that accepts them.

For example, here is the result for facebook/react:

{
  "sha": "a4bc8ae4c1db471bb34d908dd890a09d4c774303",
  "HEADRef": "refs/heads/main"
}

Home

/

Renders the latest version of the collected.press readme.

It does this by:

  1. It reads the HEAD ref’s SHA from the RoyalIcing/collected-press GitHub repo.
  2. It loads the Markdown for the README.md file at that SHA.
  3. It renders that Markdown to HTML.
  4. It links to CSS inside a HTML <head> with the rendered Markdown inside a <body>.