Ox Content

github.ts

Source

getAttribute

function

Get element attribute value.

Source

function getAttribute(el: Element, name: string): string | undefined

Returns

string | undefined -


formatNumber

function

Format number with K/M suffix.

Source

function formatNumber(num: number): string

Returns

string -


fetchRepoData

function

Fetch repository data from GitHub API.

Source

export async function fetchRepoData(
  repo: string,
  options: Required<GitHubOptions>,
  ): Promise<GitHubRepoData | null>

Returns

Promise<GitHubRepoData | null> -


createGitHubCard

function

Create GitHub card element from repo data.

Source

function createGitHubCard(repoData: GitHubRepoData): Element

Returns

Element -


createFallbackCard

function

Create fallback element when repo data is unavailable.

Source

function createFallbackCard(repo: string): Element

Returns

Element -


collectGitHubRepos

function

Collect all GitHub repos from HTML for pre-fetching.

Source

export async function collectGitHubRepos(html: string): Promise<string[]>

Returns

Promise<string[]> -


prefetchGitHubRepos

function

Pre-fetch all GitHub repos data.

Source

export async function prefetchGitHubRepos(
  repos: string[],
  options?: GitHubOptions,
  ): Promise<Map<string, GitHubRepoData | null>>

Returns

Promise<Map<string, GitHubRepoData | null>> -


rehypeGitHub

function

Rehype plugin to transform GitHub components.

Source

function rehypeGitHub(repoDataMap: Map<string, GitHubRepoData | null>)

transformGitHub

function

Transform GitHub components in HTML.

Source

export async function transformGitHub(
  html: string,
  repoDataMap?: Map<string, GitHubRepoData | null>,
  options?: GitHubOptions,
  ): Promise<string>

Returns

Promise<string> -