support github account stats

This commit is contained in:
Ayo 2022-09-24 19:52:17 +02:00
parent 13b5dda0f1
commit 9623faab43
7 changed files with 29 additions and 20 deletions

View file

@ -1,5 +1,3 @@
// Do not write code directly here, instead use the `src` folder!
// What you should do here is re-exports all the things you want your user to access, ex:
// export { HelloWorld } from "./src/main.ts"
// export type { HelloWorldResult } from "./src/types.ts"
import GithubStats from './src/GithubStats.astro';
export default GithubStats;
export * from './src/GithubStats.astro';

8
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "astro-component-name",
"version": "0.1.0",
"name": "astro-github-stats",
"version": "0.0.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "astro-component-name",
"version": "0.1.0",
"name": "astro-github-stats",
"version": "0.0.1",
"devDependencies": {
"@types/chai": "^4.3.3",
"@types/eslint": "^8.4.6",

View file

@ -1,12 +1,17 @@
{
"name": "astro-component-name",
"version": "0.1.0",
"name": "astro-github-stats",
"version": "0.0.1",
"author": {
"name": "Ayo Ayco",
"email": "ramon.aycojr@gmail.com",
"url": "https://ayco.io"
},
"type": "module",
"exports": {
".": "./index.ts"
},
"files": [
"src",
"src/GithubStats.astro",
"index.ts"
],
"keywords": [
@ -15,7 +20,8 @@
"scripts": {
"test": "mocha --parallel --timeout 15000",
"format": "prettier -w .",
"lint": "eslint . --ext .ts,.js"
"lint": "eslint . --ext .ts,.js",
"build": "tsc"
},
"devDependencies": {
"@types/chai": "^4.3.3",

View file

@ -1,3 +0,0 @@
---
// Write your component code in this file!
---

9
src/GithubStats.astro Normal file
View file

@ -0,0 +1,9 @@
---
const { username } = Astro.props;
const url = "https://github-readme-stats.vercel.app/api/"
+ `?username=${username}`;
---
<img src={url} />

View file

@ -1 +0,0 @@
// Write your component's code here!

View file

@ -13,12 +13,12 @@ describe('Example Tests', () => {
// First get the component's output, this returns an object containing the generated html (`.html`)
before(async () => {
component = await getComponentOutput('./src/Component.astro');
component = await getComponentOutput('./src/GithubStats.astro');
});
// Unless you modified /src/Component.astro, this should pass, as the component is empty apart from the frontmatter and new lines
it('example component should be empty', () => {
expect(component.html).to.equal('\n');
it('example component should not be empty', () => {
expect(component.html).not.to.equal('\n');
});
});
});