-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
159 additions
and
6 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,41 @@ | ||
import gitlog from 'gitlog'; | ||
|
||
// You can update your Git author name to your proper name here! | ||
const authorNames: Record<string, string> = { | ||
kishan: 'Kishan Sharma', | ||
}; | ||
|
||
type AuthorFrontMatter = { | ||
additional_authors?: string; | ||
override_authors?: string; | ||
}; | ||
|
||
export async function getGitContributors( | ||
path: string, | ||
frontMatter: AuthorFrontMatter, | ||
): Promise<string[]> { | ||
if (frontMatter.override_authors) { | ||
return frontMatter.override_authors | ||
.split(',') | ||
.map((author) => author.trim()); | ||
} | ||
|
||
const authors = frontMatter.additional_authors | ||
? frontMatter.additional_authors.split(',').map((author) => author.trim()) | ||
: []; | ||
|
||
const commits = await gitlog({ | ||
repo: __dirname, | ||
file: path, | ||
fields: ['authorName'], | ||
number: 100, | ||
}); | ||
|
||
for (const commit of commits) { | ||
if (!authors.includes(commit.authorName)) { | ||
authors.push(commit.authorName); | ||
} | ||
} | ||
|
||
return authors.map((name) => authorNames[name] || name); | ||
} |
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,14 @@ | ||
import React from 'react'; | ||
import Content from '@theme-original/DocItem/Content'; | ||
import type ContentType from '@theme/DocItem/Content'; | ||
import type { WrapperProps } from '@docusaurus/types'; | ||
|
||
type Props = WrapperProps<typeof ContentType>; | ||
|
||
export default function ContentWrapper(props: Props): JSX.Element { | ||
return ( | ||
<div className="content-styling"> | ||
<Content {...props} /> | ||
</div> | ||
); | ||
} |
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,45 @@ | ||
import React from 'react'; | ||
import clsx from 'clsx'; | ||
import EditThisPage from '@theme/EditThisPage'; | ||
import type { Props } from '@theme/EditMetaRow'; | ||
|
||
import LastUpdated from '@theme/LastUpdated'; | ||
import styles from './styles.module.css'; | ||
import { useDoc } from '@docusaurus/theme-common/internal'; | ||
|
||
export default function EditMetaRow({ | ||
className, | ||
editUrl, | ||
lastUpdatedAt, | ||
lastUpdatedBy, | ||
}: Props): JSX.Element { | ||
const doc = useDoc(); | ||
const authors = (doc.frontMatter as any).authors || []; | ||
const additionalAuthors = authors.filter( | ||
(name: string) => name !== lastUpdatedBy, | ||
); | ||
|
||
let additionalAuthorsString = ''; | ||
for (let i = 0; i < additionalAuthors.length; i++) { | ||
additionalAuthorsString += additionalAuthors[i]; | ||
if (i + 2 === additionalAuthors.length) additionalAuthorsString += ' and '; | ||
else if (i + 2 < additionalAuthors.length) additionalAuthorsString += ', '; | ||
} | ||
|
||
return ( | ||
<div className={clsx('row', className)}> | ||
<div className="col">{editUrl && <EditThisPage editUrl={editUrl} />}</div> | ||
<div className={clsx('col', styles.lastUpdated)}> | ||
{(lastUpdatedAt || lastUpdatedBy) && ( | ||
<LastUpdated | ||
lastUpdatedAt={lastUpdatedAt} | ||
lastUpdatedBy={lastUpdatedBy} | ||
/> | ||
)} | ||
{additionalAuthorsString && ( | ||
<p>Additional Contributors: {additionalAuthorsString}</p> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
} |
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,11 @@ | ||
.lastUpdated { | ||
font-size: smaller; | ||
font-style: italic; | ||
margin-top: 0.2rem; | ||
} | ||
|
||
@media (min-width: 997px) { | ||
.lastUpdated { | ||
text-align: right; | ||
} | ||
} |