-
-
Notifications
You must be signed in to change notification settings - Fork 730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds contributors to docs #6900
Merged
Merged
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b78584a
docs: Show contributors
alvinometric 539827e
dummy titles
alvinometric d2dfe9b
added job titles for Unleash contributors
alvinometric a72748e
Merge branch 'main' into alvin/docs-contributors
alvinometric 6848e8f
improved contributors UI
alvinometric f0ff1e4
Small revert: Let's keep the PR focused
alvinometric 6970dd1
code cleanup
alvinometric 53dc49c
Updates based on code reviews
alvinometric ef2e275
Fixed SDK contributors not showing
alvinometric ff024f4
new contributor UI
alvinometric 255641b
UI improvements
alvinometric a5e4392
Merge branch 'main' into alvin/docs-contributors
alvinometric 7b3c15f
correct titles
alvinometric File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// biome-ignore lint/correctness/noUnusedImports: Needs this for React to work | ||
import React, { useState, useEffect } from 'react'; | ||
import { getContributors } from './contributors'; | ||
import styles from './contributors.module.scss'; | ||
|
||
const unleashTeam = new Map([ | ||
['alvinometric', 'developer advocate, Unleash'], | ||
['andreas-unleash', 'senior software engineer, Unleash'], | ||
['chriswk', 'senior software engineer, Unleash'], | ||
['daveleek', 'senior software engineer, Unleash'], | ||
['FredrikOseberg', 'senior software engineer, Unleash'], | ||
['gardleopard', 'senior software engineer, Unleash'], | ||
['gastonfournier', 'senior software engineer, Unleash'], | ||
['ivarconr', 'co-founder, Unleash'], | ||
['kwasniew', 'senior software engineer, Unleash'], | ||
['nnennandukwe', 'developer advocate, Unleash'], | ||
['nunogois', 'senior software engineer, Unleash'], | ||
['sighphyre', 'senior software engineer, Unleash'], | ||
['sjaanus', 'senior software engineer, Unleash'], | ||
['thomasheartman', 'senior software engineer, Unleash'], | ||
['Tymek', 'senior software engineer, Unleash'], | ||
]); | ||
|
||
const GitHubContributors = ({ owner, repo, filePath }) => { | ||
const [contributors, setContributors] = useState([]); | ||
const url = `https://api.github.com/repos/${owner}/${repo}/commits?path=${filePath}`; | ||
|
||
useEffect(() => { | ||
const fetchFileContributors = () => { | ||
fetch(url) | ||
.then((response) => response.json()) | ||
.then((commits) => { | ||
console.log(commits); | ||
const contributors = getContributors(commits); | ||
console.log(contributors); | ||
contributors.sort((a, b) => { | ||
if (unleashTeam.has(a.login)) { | ||
return -1; | ||
} | ||
return 1; | ||
}); | ||
setContributors(contributors); | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
setContributors([]); | ||
}); | ||
}; | ||
|
||
fetchFileContributors(); | ||
}, []); | ||
|
||
if (!contributors.length) { | ||
return <h3>Fetching contributors...</h3>; | ||
} | ||
|
||
return ( | ||
<div className={styles.contributors}> | ||
<h3>Contributors</h3> | ||
|
||
<ul className={styles.wrapper}> | ||
{contributors?.map((contributor) => { | ||
const isUnleashTeam = unleashTeam.has(contributor.login); | ||
const name = isUnleashTeam | ||
? `${contributor.login}, ${unleashTeam.get( | ||
contributor.login, | ||
)}` | ||
: contributor.login; | ||
return ( | ||
<li | ||
key={contributor.login} | ||
className={styles.contributor} | ||
> | ||
<a | ||
href={contributor.html_url} | ||
className={isUnleashTeam ? styles.unleash : ''} | ||
title={`@${name}`} | ||
> | ||
<img | ||
src={contributor.avatar_url} | ||
alt={contributor.login} | ||
width={70} | ||
/> | ||
</a> | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
</div> | ||
); | ||
}; | ||
|
||
export default GitHubContributors; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export const getContributors = (commits) => { | ||
// filter out commits that don't have an author | ||
const commitsWithAuthors = commits.filter((commit) => !!commit.author); | ||
|
||
// use a Set to deduplicate the list of contributors | ||
const contributorSet = new Set(); | ||
for (const commit of commitsWithAuthors) { | ||
contributorSet.add(JSON.stringify(commit.author)); | ||
} | ||
|
||
const contributors = Array.from(contributorSet).map((str) => { | ||
const contributor = JSON.parse(str); | ||
const { login, html_url, avatar_url } = contributor; | ||
return { login, html_url, avatar_url }; | ||
}); | ||
|
||
// sort alphabetically | ||
contributors.sort((a, b) => { | ||
return a.login.localeCompare(b.login); | ||
}); | ||
|
||
return contributors; | ||
}; |
alvinometric marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
.contributors { | ||
margin-block: var(--ifm-spacing-vertical); | ||
} | ||
|
||
.wrapper { | ||
display: flex; | ||
flex-wrap: wrap; | ||
margin: 0; | ||
padding: 0; | ||
|
||
li{ | ||
list-style: none; | ||
} | ||
} | ||
|
||
.unleash{ | ||
position: relative; | ||
display: block; | ||
} | ||
|
||
.unleash:before{ | ||
display: block; | ||
position: absolute; | ||
z-index: 2; | ||
content: ''; | ||
top: -5px; | ||
right: -5px; | ||
width: 30px; | ||
height: 30px; | ||
background-image: url(/img/logo.svg); | ||
} | ||
|
||
.contributor { | ||
margin: 5px 10px 5px 0; | ||
display: flex; | ||
gap: 10px; | ||
alvinometric marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
img{ | ||
border-radius: 100%; | ||
alvinometric marked this conversation as resolved.
Show resolved
Hide resolved
|
||
border: 2px solid var(--ifm-color-emphasis-300); | ||
alvinometric marked this conversation as resolved.
Show resolved
Hide resolved
|
||
transition: border-color var(--ifm-transition-fast) var(--ifm-transition-timing-default), | ||
scale var(--ifm-transition-fast) var(--ifm-transition-timing-default); | ||
|
||
} | ||
|
||
figcaption { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: flex-start; | ||
} | ||
} | ||
|
||
.contributor img:hover{ | ||
border-color: var(--ifm-pagination-nav-color-hover); | ||
scale: 1.1; | ||
} | ||
|
||
@media (max-width: 600px) { | ||
.wrapper { | ||
display: block; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
const commits = [ | ||
{ | ||
sha: '2754c26f2e022b623e46e08fc1108b350710ef91', | ||
node_id: | ||
'C_kwDOAXdJ9doAKDI3NTRjMjZmMmUwMjJiNjIzZTQ2ZTA4ZmMxMTA4YjM1MDcxMGVmOTE', | ||
url: 'https://api.github.com/repos/Unleash/unleash/commits/2754c26f2e022b623e46e08fc1108b350710ef91', | ||
html_url: | ||
'https://github.com/Unleash/unleash/commit/2754c26f2e022b623e46e08fc1108b350710ef91', | ||
comments_url: | ||
'https://api.github.com/repos/Unleash/unleash/commits/2754c26f2e022b623e46e08fc1108b350710ef91/comments', | ||
author: { | ||
login: 'markunl', | ||
id: 128738155, | ||
node_id: 'U_kgDOB6xjaw', | ||
avatar_url: 'https://avatars.githubusercontent.com/u/128738155?v=4', | ||
gravatar_id: '', | ||
url: 'https://api.github.com/users/markunl', | ||
html_url: 'https://github.com/markunl', | ||
type: 'User', | ||
site_admin: false, | ||
}, | ||
}, | ||
{ | ||
sha: 'd5fbd0b743cc99791d34864c70f78985cc83b2d8', | ||
node_id: | ||
'C_kwDOAXdJ9doAKGQ1ZmJkMGI3NDNjYzk5NzkxZDM0ODY0YzcwZjc4OTg1Y2M4M2IyZDg', | ||
url: 'https://api.github.com/repos/Unleash/unleash/commits/d5fbd0b743cc99791d34864c70f78985cc83b2d8', | ||
html_url: | ||
'https://github.com/Unleash/unleash/commit/d5fbd0b743cc99791d34864c70f78985cc83b2d8', | ||
comments_url: | ||
'https://api.github.com/repos/Unleash/unleash/commits/d5fbd0b743cc99791d34864c70f78985cc83b2d8/comments', | ||
author: { | ||
login: 'thomasheartman', | ||
id: 17786332, | ||
node_id: 'MDQ6VXNlcjE3Nzg2MzMy', | ||
avatar_url: 'https://avatars.githubusercontent.com/u/17786332?v=4', | ||
gravatar_id: '', | ||
url: 'https://api.github.com/users/thomasheartman', | ||
html_url: 'https://github.com/thomasheartman', | ||
type: 'User', | ||
site_admin: false, | ||
}, | ||
}, | ||
{ | ||
sha: 'ebcab898e7610082d3ada81ab0b729ba1f17655d', | ||
node_id: | ||
'C_kwDOAXdJ9doAKGViY2FiODk4ZTc2MTAwODJkM2FkYTgxYWIwYjcyOWJhMWYxNzY1NWQ', | ||
url: 'https://api.github.com/repos/Unleash/unleash/commits/ebcab898e7610082d3ada81ab0b729ba1f17655d', | ||
html_url: | ||
'https://github.com/Unleash/unleash/commit/ebcab898e7610082d3ada81ab0b729ba1f17655d', | ||
comments_url: | ||
'https://api.github.com/repos/Unleash/unleash/commits/ebcab898e7610082d3ada81ab0b729ba1f17655d/comments', | ||
author: { | ||
login: 'thomasheartman', | ||
id: 17786332, | ||
node_id: 'MDQ6VXNlcjE3Nzg2MzMy', | ||
avatar_url: 'https://avatars.githubusercontent.com/u/17786332?v=4', | ||
gravatar_id: '', | ||
url: 'https://api.github.com/users/thomasheartman', | ||
html_url: 'https://github.com/thomasheartman', | ||
type: 'User', | ||
site_admin: false, | ||
}, | ||
}, | ||
{ | ||
sha: 'ead86ed62191777895d5a5f1a7c58f16a87ebde7', | ||
node_id: | ||
'C_kwDOAXdJ9doAKGVhZDg2ZWQ2MjE5MTc3Nzg5NWQ1YTVmMWE3YzU4ZjE2YTg3ZWJkZTc', | ||
author: { | ||
login: 'thomasheartman', | ||
id: 17786332, | ||
node_id: 'MDQ6VXNlcjE3Nzg2MzMy', | ||
avatar_url: 'https://avatars.githubusercontent.com/u/17786332?v=4', | ||
gravatar_id: '', | ||
url: 'https://api.github.com/users/thomasheartman', | ||
html_url: 'https://github.com/thomasheartman', | ||
type: 'User', | ||
site_admin: false, | ||
}, | ||
}, | ||
]; | ||
|
||
const expectedContributors = [ | ||
{ | ||
login: 'thomasheartman', | ||
html_url: 'https://github.com/thomasheartman', | ||
avatar_url: 'https://avatars.githubusercontent.com/u/17786332?v=4', | ||
}, | ||
{ | ||
login: 'markunl', | ||
html_url: 'https://github.com/markunl', | ||
avatar_url: 'https://avatars.githubusercontent.com/u/128738155?v=4', | ||
}, | ||
]; | ||
|
||
test('getContributors should return the correct list of contributors', () => { | ||
const contributors = getContributors(commits); | ||
expect(contributors).toEqual(expectedContributors); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// biome-ignore lint/correctness/noUnusedImports: Needs this for React to work | ||
import React from 'react'; | ||
import Footer from '@theme-original/DocItem/Footer'; | ||
import { useDoc } from '@docusaurus/theme-common/internal'; | ||
import GitHubContributors from './GitHubContributors'; | ||
import GitUrlParse from 'git-url-parse'; | ||
|
||
export default function FooterWrapper(props) { | ||
const { metadata } = useDoc(); | ||
const file = metadata.editUrl; | ||
|
||
if (!file) { | ||
return <Footer {...props} />; | ||
} | ||
|
||
const info = GitUrlParse(file); | ||
const { name, owner, filepath } = info; | ||
|
||
return ( | ||
<> | ||
<Footer {...props} /> | ||
<GitHubContributors repo={name} owner={owner} filePath={filepath} /> | ||
</> | ||
); | ||
} |
alvinometric marked this conversation as resolved.
Show resolved
Hide resolved
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, we probably wanna remove these logs, though: