github.ts
getAttribute
function
Get element attribute value.
function getAttribute(el: Element, name: string): string | undefined
Returns
string | undefined -
formatNumber
function
Format number with K/M suffix.
function formatNumber(num: number): string
Returns
string -
fetchRepoData
function
Fetch repository data from GitHub API.
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.
function createGitHubCard(repoData: GitHubRepoData): Element
Returns
Element -
createFallbackCard
function
Create fallback element when repo data is unavailable.
function createFallbackCard(repo: string): Element
Returns
Element -
collectGitHubRepos
function
Collect all GitHub repos from HTML for pre-fetching.
export async function collectGitHubRepos(html: string): Promise<string[]>
Returns
Promise<string[]> -
prefetchGitHubRepos
function
Pre-fetch all GitHub repos data.
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.
function rehypeGitHub(repoDataMap: Map<string, GitHubRepoData | null>)
transformGitHub
function
Transform GitHub components in HTML.
export async function transformGitHub(
html: string,
repoDataMap?: Map<string, GitHubRepoData | null>,
options?: GitHubOptions,
): Promise<string>
Returns
Promise<string> -