mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +01:00
Hello! We wanted to make the docs less impersonal, so we decided to add contributors. Now each doc page that has an `editUrl` (i.e, isn't generated) shows a list of everyone that contributed to it. This list is generated by: 1. Running `swizzle` on the `DocItem/Footer` in Docusaurus. 2. Grabbing metadata for the current file using an internal docusaurus API (Thank you to @homotechsual for the help there) 3. Getting the commits to the file in question with the GitHub API ![image](https://github.com/Unleash/unleash/assets/107407814/fd9c92ef-36ab-4d9e-ac11-6d724fd55d11) <details> <summary> Here's the command I ran, for posterity </summary> <code>npm run swizzle @docusaurus/theme-classic DocItem/Footer -- --wrap</code> </details> ## Discussion points 1. Design. What do you think of the layout? 2. Right now I'm hardcoding the info of Unleash team members. This creates a small maintenance burden, but it's something we wanted to add.
26 lines
737 B
JavaScript
26 lines
737 B
JavaScript
// 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} />
|
|
</>
|
|
);
|
|
}
|