Skip to content

Commit

Permalink
Wip (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertnitu02 authored Oct 23, 2024
1 parent 5296c30 commit fb3444d
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 1 deletion.
39 changes: 39 additions & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
import { defineConfig } from 'vitepress'

import Git from 'simple-git'

const git = Git({
maxConcurrentProcesses: 200
})

async function getContributorsAt(path: string) {
try {
const list = (
await git.raw(['log', '--pretty=format:"%an|%ae"', '--', path])
)
.split('\n')
.map((i) => i.slice(1, -1).split('|') as [string, string])
const map: Record<string, { name: string; count: number }> = {}

list
.filter((i) => i[1])
.forEach((i) => {
if (!map[i[1]]) {
map[i[1]] = {
name: i[0],
count: 0
}
}
map[i[1]].count++
})

return Object.values(map)
.sort((a, b) => b.count - a.count)
.map((i) => i.name)
} catch (e) {
console.error(e)
return []
}
}

export default defineConfig({
title: "B-Zone V Wiki",
description: "Wiki page - B-Zone V Roleplay",
Expand Down Expand Up @@ -137,5 +173,8 @@ export default defineConfig({
footer: {
copyright: 'Copyright © 2024 B-Zone V'
}
},
async transformPageData({ relativePath }) {
return { contributors: await getContributorsAt(relativePath) }
}
})
8 changes: 8 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<script setup>
import { useData } from 'vitepress'
import { computed } from 'vue'

const { page } = useData()
const contributors = computed(() => page.value.contributors)
</script>

# B-Zone V Wiki

## Bun venit!
Expand Down
51 changes: 51 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs"
},
"dependencies": {
"simple-git": "^3.27.0"
}
}
}

0 comments on commit fb3444d

Please sign in to comment.