filter out archived repos

This commit is contained in:
Joshua Seigler 2022-10-11 17:06:08 -04:00
parent fa98694797
commit 8e21584d92
No known key found for this signature in database
2 changed files with 8 additions and 8 deletions

View file

@ -15,6 +15,7 @@ export type GithubRepo = {
stargazers_count: number stargazers_count: number
topics: string[] topics: string[]
fork: boolean fork: boolean
archived: boolean
} }
const sourceFullName = 'seigler/seigler.github.io' const sourceFullName = 'seigler/seigler.github.io'
@ -33,6 +34,8 @@ const topics = computed(() => {
const isLoading = signal(true) const isLoading = signal(true)
const filter = signal<(r: GithubRepo) => boolean>(() => true) const filter = signal<(r: GithubRepo) => boolean>(() => true)
const filteredRepos = computed(() => repos.value.filter(filter.value))
function fetchDataUntilNoNext(uri: string) { function fetchDataUntilNoNext(uri: string) {
fetch(uri) fetch(uri)
.then((response) => { .then((response) => {
@ -46,8 +49,8 @@ function fetchDataUntilNoNext(uri: string) {
} }
return response.json() return response.json()
}) })
.then((data) => { .then((data: GithubRepo[]) => {
repos.value = repos.value.concat(data) repos.value = repos.value.concat(data.filter((r) => !r.archived))
if (isLoading.value === false) { if (isLoading.value === false) {
repos.value = [ repos.value = [
...repos.value.sort((a, b) => ...repos.value.sort((a, b) =>
@ -95,7 +98,7 @@ function App() {
<span class="loader"></span> <span class="loader"></span>
) : ( ) : (
<main class="grid-container"> <main class="grid-container">
{repos.value.filter(filter.value).map((repo) => ( {filteredRepos.value.map((repo) => (
<div key={repo.id} className="grid-item" style={{ '--width': '4' }}> <div key={repo.id} className="grid-item" style={{ '--width': '4' }}>
<RepoCard repo={repo} /> <RepoCard repo={repo} />
</div> </div>

View file

@ -1,19 +1,16 @@
import { h, Fragment, render } from 'preact' import { h, Fragment, render } from 'preact'
import type { GithubRepo } from './App' import type { GithubRepo } from './App'
import dayjs from 'dayjs' import * as dayjs from 'dayjs'
export function RepoCard({ repo }: { repo: GithubRepo }) { export function RepoCard({ repo }: { repo: GithubRepo }) {
const { const {
id,
name, name,
full_name,
html_url, html_url,
created_at, created_at,
description, description,
homepage, homepage,
stargazers_count, stargazers_count,
topics, topics
fork
} = repo } = repo
return ( return (
<div class="card"> <div class="card">