astro-contributors 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/components/AllContributors.astro +183 -0
- package/index.ts +1 -0
- package/libs/getAllContributorsRc.ts +47 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# astro-contributors
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`64612b7`](https://github.com/trueberryless-org/astro-contributors/commit/64612b7348c6df8c29ed914c8afb20308b4c6389) Thanks [@trueberryless](https://github.com/trueberryless)! - Add support for All Contributors standard. Check out the [new component documentation](https://astro-contributors.trueberryless.org/all-contributors/) for details.
|
|
8
|
+
|
|
9
|
+
## 0.7.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#76](https://github.com/trueberryless-org/astro-contributors/pull/76) [`1b3a885`](https://github.com/trueberryless-org/astro-contributors/commit/1b3a885d7427c8be85e1ae53f161d92f04e44154) Thanks [@trueberryless](https://github.com/trueberryless)! - Adds support for Astro v6, drops support for Astro v5.
|
|
14
|
+
|
|
15
|
+
⚠️ **BREAKING CHANGE:** The minimum supported version of Starlight is now `0.38.0`.
|
|
16
|
+
|
|
17
|
+
Please follow the [upgrade guide](https://github.com/withastro/starlight/releases/tag/%40astrojs%2Fstarlight%400.38.0) to update your project.
|
|
18
|
+
|
|
3
19
|
## 0.6.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { getAllContributorsFromRc } from "../libs/getAllContributorsRc";
|
|
3
|
+
|
|
4
|
+
export interface Props {
|
|
5
|
+
focusColor?: string;
|
|
6
|
+
bgColor?: string;
|
|
7
|
+
borderColor?: string;
|
|
8
|
+
textColor?: string;
|
|
9
|
+
badgeBgColor?: string;
|
|
10
|
+
badgeTextColor?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
focusColor,
|
|
15
|
+
bgColor,
|
|
16
|
+
borderColor,
|
|
17
|
+
textColor,
|
|
18
|
+
badgeBgColor,
|
|
19
|
+
badgeTextColor,
|
|
20
|
+
} = Astro.props as Props;
|
|
21
|
+
|
|
22
|
+
const styleOverride = {
|
|
23
|
+
...(focusColor && { "--ac-focus-color": focusColor }),
|
|
24
|
+
...(bgColor && { "--ac-bg-color": bgColor }),
|
|
25
|
+
...(borderColor && { "--ac-border-color": borderColor }),
|
|
26
|
+
...(textColor && { "--ac-text-color": textColor }),
|
|
27
|
+
...(badgeBgColor && { "--ac-badge-bg-color": badgeBgColor }),
|
|
28
|
+
...(badgeTextColor && { "--ac-badge-text-color": badgeTextColor }),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const contributors = getAllContributorsFromRc();
|
|
32
|
+
|
|
33
|
+
const emojiMap: Record<string, string> = {
|
|
34
|
+
audio: "🔊",
|
|
35
|
+
a11y: "♿️",
|
|
36
|
+
bug: "🐛",
|
|
37
|
+
blog: "📝",
|
|
38
|
+
business: "💼",
|
|
39
|
+
code: "💻",
|
|
40
|
+
content: "🖋",
|
|
41
|
+
data: "🔣",
|
|
42
|
+
design: "🎨",
|
|
43
|
+
doc: "📖",
|
|
44
|
+
eventOrganizing: "📋",
|
|
45
|
+
example: "💡",
|
|
46
|
+
financial: "💵",
|
|
47
|
+
fundingFinding: "🔍",
|
|
48
|
+
ideas: "🤔",
|
|
49
|
+
infra: "🚇",
|
|
50
|
+
maintenance: "🚧",
|
|
51
|
+
mentoring: "🧑🏫",
|
|
52
|
+
platform: "📦",
|
|
53
|
+
plugin: "🔌",
|
|
54
|
+
projectManagement: "📆",
|
|
55
|
+
question: "💬",
|
|
56
|
+
research: "🔬",
|
|
57
|
+
review: "👀",
|
|
58
|
+
security: "🛡️",
|
|
59
|
+
tool: "🔧",
|
|
60
|
+
translation: "🌍",
|
|
61
|
+
test: "⚠️",
|
|
62
|
+
tutorial: "✅",
|
|
63
|
+
talk: "📢",
|
|
64
|
+
userTesting: "📓",
|
|
65
|
+
video: "📹",
|
|
66
|
+
};
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
{
|
|
70
|
+
contributors.length > 0 ? (
|
|
71
|
+
<div
|
|
72
|
+
class="all-contributors-grid"
|
|
73
|
+
style={Object.keys(styleOverride).length > 0 ? styleOverride : undefined}
|
|
74
|
+
>
|
|
75
|
+
{contributors.map((contributor) => (
|
|
76
|
+
<a
|
|
77
|
+
href={contributor.profile}
|
|
78
|
+
class="contributor-card"
|
|
79
|
+
target="_blank"
|
|
80
|
+
rel="noopener noreferrer"
|
|
81
|
+
>
|
|
82
|
+
<img
|
|
83
|
+
src={contributor.avatar_url}
|
|
84
|
+
alt={contributor.name}
|
|
85
|
+
title={contributor.name}
|
|
86
|
+
width="64"
|
|
87
|
+
height="64"
|
|
88
|
+
loading="lazy"
|
|
89
|
+
/>
|
|
90
|
+
<div class="contributor-info">
|
|
91
|
+
<span class="contributor-name">{contributor.name}</span>
|
|
92
|
+
<div class="contributor-badges">
|
|
93
|
+
{contributor.contributions.map((type) => (
|
|
94
|
+
<span class="badge" title={`Contribution: ${type}`}>
|
|
95
|
+
{emojiMap[type] || "✨"} {type}
|
|
96
|
+
</span>
|
|
97
|
+
))}
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</a>
|
|
101
|
+
))}
|
|
102
|
+
</div>
|
|
103
|
+
) : (
|
|
104
|
+
<p>No .all-contributorsrc file found or no contributors listed.</p>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
<style>
|
|
109
|
+
.all-contributors-grid {
|
|
110
|
+
--local-focus: var(--ac-focus-color, var(--sl-color-accent, #3b82f6));
|
|
111
|
+
--local-bg: var(--ac-bg-color, var(--sl-color-bg-nav, #f8f9fa));
|
|
112
|
+
--local-border: var(--ac-border-color, var(--sl-color-hairline, #e5e7eb));
|
|
113
|
+
--local-text: var(--ac-text-color, var(--sl-color-text, #111827));
|
|
114
|
+
--local-badge-bg: var(--ac-badge-bg-color, var(--sl-color-black, #1a1a1a));
|
|
115
|
+
--local-badge-text: var(
|
|
116
|
+
--ac-badge-text-color,
|
|
117
|
+
var(--sl-color-text, #ffffff)
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
display: grid;
|
|
121
|
+
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
|
|
122
|
+
gap: 1rem;
|
|
123
|
+
padding: 1rem 0;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.contributor-card {
|
|
127
|
+
display: flex;
|
|
128
|
+
flex-direction: column;
|
|
129
|
+
align-items: center;
|
|
130
|
+
text-align: center;
|
|
131
|
+
padding: 1.25rem 0.5rem;
|
|
132
|
+
border-radius: 0.5rem;
|
|
133
|
+
background: var(--local-bg);
|
|
134
|
+
border: 1px solid var(--local-border);
|
|
135
|
+
text-decoration: none;
|
|
136
|
+
color: var(--local-text);
|
|
137
|
+
transition:
|
|
138
|
+
transform 0.2s ease,
|
|
139
|
+
box-shadow 0.2s ease;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.contributor-card:hover,
|
|
143
|
+
.contributor-card:focus-visible {
|
|
144
|
+
transform: translateY(-2px);
|
|
145
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
|
146
|
+
outline: 2px solid var(--local-focus);
|
|
147
|
+
outline-offset: 2px;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.contributor-card img {
|
|
151
|
+
border-radius: 50%;
|
|
152
|
+
margin-bottom: 0.75rem;
|
|
153
|
+
background-color: var(--local-border);
|
|
154
|
+
object-fit: cover;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.contributor-name {
|
|
158
|
+
font-weight: 600;
|
|
159
|
+
font-size: 0.9rem;
|
|
160
|
+
margin-bottom: 0.5rem;
|
|
161
|
+
line-height: 1.2;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.contributor-badges {
|
|
165
|
+
display: flex;
|
|
166
|
+
flex-wrap: wrap;
|
|
167
|
+
gap: 0.35rem;
|
|
168
|
+
justify-content: center;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.badge {
|
|
172
|
+
font-size: 0.7rem;
|
|
173
|
+
padding: 0.15rem 0.4rem;
|
|
174
|
+
border-radius: 0.25rem;
|
|
175
|
+
background: var(--local-badge-bg);
|
|
176
|
+
border: 1px solid var(--local-border);
|
|
177
|
+
color: var(--local-badge-text);
|
|
178
|
+
display: inline-flex;
|
|
179
|
+
align-items: center;
|
|
180
|
+
gap: 0.25rem;
|
|
181
|
+
text-transform: capitalize;
|
|
182
|
+
}
|
|
183
|
+
</style>
|
package/index.ts
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
export interface RcContributor {
|
|
5
|
+
login: string;
|
|
6
|
+
name: string;
|
|
7
|
+
avatar_url: string;
|
|
8
|
+
profile: string;
|
|
9
|
+
contributions: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface AllContributorsRc {
|
|
13
|
+
contributors: RcContributor[];
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function findAllContributorsRc(): AllContributorsRc | null {
|
|
18
|
+
let currentDir = process.cwd();
|
|
19
|
+
|
|
20
|
+
while (currentDir) {
|
|
21
|
+
const filePath = path.join(currentDir, ".all-contributorsrc");
|
|
22
|
+
|
|
23
|
+
if (fs.existsSync(filePath)) {
|
|
24
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
25
|
+
const parsed = JSON.parse(content) as unknown;
|
|
26
|
+
if (
|
|
27
|
+
typeof parsed === "object" &&
|
|
28
|
+
parsed !== null &&
|
|
29
|
+
Array.isArray((parsed as { contributors?: unknown }).contributors)
|
|
30
|
+
) {
|
|
31
|
+
return parsed as AllContributorsRc;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const parentDir = path.dirname(currentDir);
|
|
37
|
+
if (parentDir === currentDir) break;
|
|
38
|
+
currentDir = parentDir;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function getAllContributorsFromRc(): RcContributor[] {
|
|
45
|
+
const data = findAllContributorsRc();
|
|
46
|
+
return Array.isArray(data?.contributors) ? data.contributors : [];
|
|
47
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-contributors",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Display a list of all contributors to your project",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"starlight",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"astro": "^
|
|
28
|
+
"astro": "^6.0.0"
|
|
29
29
|
},
|
|
30
30
|
"engines": {
|
|
31
31
|
"node": ">=22.12.0"
|