Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

astro-loader-github-repos

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

astro-loader-github-repos

Load GitHub repository data into the Astro content layer

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-93.33%
Maintainers
0
Weekly downloads
 
Created
Source

Astro Loader for GitHub Repositories

This package enables you to load the data of the repositories in a GitHub org, and use the data in your Astro site.

Currently it provides githubReposLoader, which loads the repositories of a single org. By default it will load all repositories, but you can filter the types of repos loaded.

Installation

npm install astro-loader-github-repos

Usage

This package requires Astro 4.14.0 or later. You must enable the experimental content layer in Astro unless you are using version 5.0.0-beta or later. You can do this by adding the following to your astro.config.mjs:

export default defineConfig({
  // ...
  experimental: {
    contentLayer: true,
  },
});

You can then use the loader in your content configuration:

// src/content/config.ts
import { defineCollection } from "astro:content";
import { githubReposLoader } from "astro-loader-github-repos";

const repos = defineCollection({
  loader: githubReposLoader({
    auth: "YOUR-TOKEN", // Optional if only public repositories are requested
    org: "withastro",
    type: "public",
  }),
  // The loader provides its own type schema, so you don't need to provide one
});

export const collections = { repos };

You can then use these like any other content collection in Astro:

---
import { getCollection } from "astro:content";
import Layout from "../layouts/Layout.astro";

const repos = await getCollection("repos");
---

<Layout>
  {
    repos.map(async (repo) => (
      <div>
        <a href={repo.data.html_url}>{repo.data.full_name}</a>
        <span>{repo.data.stargazers_count} stars</span>
      </div>
    ))
  }
</Layout>

Options

The githubReposLoader function takes an options object with the following properties:

  • auth: A GitHub access token such as a personal access token or a GitHub App user access token, with at least the "Metadata" repository permissions (read). Optional if only public repositories are requested. See the GitHub API Authentication docs for more details.
  • org: The organization name for which to fetch the repositories. The name is not case sensitive.
  • type: The types of repositories to fetch. Can be one of: all, public, private, forks, sources, member. Defaults to public.

Keywords

FAQs

Package last updated on 18 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc