Skip to content

Commit 2c38213

Browse files
committed
Refactor repository fetching logic to improve module count tracking and enhance error handling
1 parent 008b95a commit 2c38213

File tree

1 file changed

+42
-11
lines changed

1 file changed

+42
-11
lines changed

docs/en/repository/index.md

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,55 @@
11
<script setup>
2-
import { repositories, Repository } from "../../data/repositories";
2+
import { ref, onMounted } from "vue"
3+
import { repositories, Repository } from "../../data/repositories"
34

4-
const repos = repositories.map((repo)=> {
5-
const r = new Repository(repo.url)
5+
const repos = ref([])
6+
const repoCount = ref(0)
7+
const moduleCount = ref(0)
68

7-
return {
8-
name: r.name,
9-
href: r.id
10-
}
9+
onMounted(async () => {
10+
let totalModules = 0
11+
12+
const fetchedRepos = await Promise.all(
13+
repositories.map(async (repo) => {
14+
const r = new Repository(repo.url)
15+
try {
16+
const response = await fetch(r.modules)
17+
const data = await response.json()
18+
totalModules += data.modules.length
19+
20+
return {
21+
name: r.name,
22+
href: r.id,
23+
}
24+
} catch {
25+
return null // ignore failed fetches
26+
}
27+
})
28+
)
29+
30+
const successfulRepos = fetchedRepos.filter(Boolean)
31+
32+
repos.value = successfulRepos
33+
repoCount.value = successfulRepos.length
34+
moduleCount.value = totalModules
1135
})
1236
</script>
1337

14-
# Repositories
38+
<h1>Repositories</h1>
39+
40+
<p>
41+
As of now, the MMRL provides access to <strong>{{ repoCount }}</strong> repositories,
42+
encompassing more than <strong>{{ moduleCount }}</strong> modules in total.
43+
These are continually maintained to ensure up-to-date functionality and compatibility.
44+
</p>
1545

1646
:::info
1747
The website will be every 6 (six) hours re-deployed so that every repository will be updated at [mmrl.dev](https://mmrl.dev)!
1848
:::
1949

2050
<ol>
21-
<li v-for="repository in repos">
22-
<a :href="repository.href">{{ repository.name }}</a>
23-
</li>
51+
<li v-for="repository in repos" :key="repository.href">
52+
<a :href="repository.href">{{ repository.name }}</a>
53+
</li>
2454
</ol>
55+

0 commit comments

Comments
 (0)