|
1 | 1 | <script setup> |
2 | | -import { repositories, Repository } from "../../data/repositories"; |
| 2 | +import { ref, onMounted } from "vue" |
| 3 | +import { repositories, Repository } from "../../data/repositories" |
3 | 4 |
|
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) |
6 | 8 |
|
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 |
11 | 35 | }) |
12 | 36 | </script> |
13 | 37 |
|
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> |
15 | 45 |
|
16 | 46 | :::info |
17 | 47 | The website will be every 6 (six) hours re-deployed so that every repository will be updated at [mmrl.dev](https://mmrl.dev)! |
18 | 48 | ::: |
19 | 49 |
|
20 | 50 | <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> |
24 | 54 | </ol> |
| 55 | + |
0 commit comments