Skip to content

Commit

Permalink
fixed bug causing contributors to not autopopulate authors when autho…
Browse files Browse the repository at this point in the history
…rs is empty
  • Loading branch information
pirog committed Apr 4, 2024
1 parent 5a1bb69 commit 6a5268e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v1.0.1 - [April 4, 2024](https://github.com/lando/vitepress-theme-default-plus/releases/tag/v1.0.1)

## Bug Fixes

* Fixed bug causing auto population of `authors` from `contributors` when `authors` is empty

## v1.0.0 - [April 4, 2024](https://github.com/lando/vitepress-theme-default-plus/releases/tag/v1.0.0)

## New Features
Expand Down
4 changes: 3 additions & 1 deletion node/normalize-frontmatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ export default async function(pageData, {
}

// prefer authors be an array
if (!pageData.frontmatter.authors) pageData.frontmatter.authors = [];
if (pageData.frontmatter.authors && !Array.isArray(pageData.frontmatter.authors)) {
pageData.frontmatter.authors = [pageData.frontmatter.authors];
}

// do a final check to make sure authors is at least an empty array
if (!pageData.frontmatter.authors) pageData.frontmatter.authors = [];

// consolidate it all into an array at frontmatter.tags
if (!frontmatter.tags) pageData.frontmatter.tags = [];
if (frontmatter.tags && typeof frontmatter.tags === 'string') pageData.frontmatter.tags = [pageData.frontmatter.tags];
Expand Down
4 changes: 3 additions & 1 deletion node/parse-collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export default async function(pageData, {
// if this is a match then do the collection stuff we need to do
if (pages.includes(relativePath) || frontmatter.collection === collection) {
// if no author is set then we should be able to set it with contrib info
if (frontmatter.authors === undefined && Array.isArray(contributors)) {
if ((frontmatter.authors === undefined
|| (Array.isArray(frontmatter.authors) && frontmatter.authors.length === 0))
&& Array.isArray(contributors)) {
frontmatter.authors = contributors;
debug('set authors %o using contributors information', frontmatter.authors.map(author => author.name));
}
Expand Down

0 comments on commit 6a5268e

Please sign in to comment.