Last active
March 29, 2020 12:12
-
-
Save AmruthPillai/ebc3b202f6b9871f1c4093ff382414f6 to your computer and use it in GitHub Desktop.
A Vue Component that Displays a Grid of Users who have Contributed to a GitHub Repo, used with VuePress for Documentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="contributors"> | |
<div v-for="i in items"> | |
<a :href="i.html_url" target="_blank" rel="noopener noreferrer"> | |
<img :src="i.avatar_url" /> | |
</a> | |
</div> | |
</div> | |
</template> | |
<script> | |
const axios = require('axios'); | |
const repo = 'AmruthPillai/Reactive-Resume'; | |
export default { | |
data() { | |
return { | |
items: [], | |
}; | |
}, | |
beforeMount() { | |
axios | |
.get(`https://api.github.com/repos/${repo}/contributors`) | |
.then(response => { | |
this.$data.items = response.data; | |
}) | |
.catch(error => { | |
console.log(error); | |
}); | |
}, | |
}; | |
</script> | |
<style> | |
.contributors { | |
margin-top: 20px; | |
display: grid; | |
grid-template-columns: repeat(10, minmax(0, 1fr)); | |
gap: 1rem; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment