-
Notifications
You must be signed in to change notification settings - Fork 55
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
🎓 Add rich affiliations to frontmatter #535
Conversation
frontmatter.affiliations | ||
?.filter((aff) => aff.id && !aff.collaboration) | ||
.map((aff, index) => { | ||
return { value: aff, ...indexAndLetter(index) }; |
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.
These changes will need to be consumed in the tex templates themselves; now, affiliations are objects instead of strings.
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.
There is also going to be a bit around @dressedfez's template that consumes the collaboration.
I think that they should be straight forward, however, we don't really have a way to version the templates which means this is a breaking change in that respect. Any better thoughts on how to handle it?
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.
I would be willing to introduce a versioning on my side. @rowanc1 which changes are necessary in the template?
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.
@fwkoch is going to open a PR!
collaboration.value
--> collaboration.value.name
in the template.
And then a small tweak to the frontmatter which will emit a warning on existing templates letting you know what to do.
The change works for both forward and backwards compatibility, in that it doesn't break the build, but the affiliation/collaboration will either not show up at all, or be [Object Object]
if you are building with the new version and using the old template.
Now that is an object there shouldn't be any other backwards-incompatible changes!
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.
@fwkoch I added some docs and a few more tests. It would be great to have your check on the one piece of logic.
if (!Object.keys(lookup).includes(value.id)) { | ||
if (Object.keys(value).length === 1 && value.id) { | ||
// This is a single object with an ID that may be defined later | ||
// Only assign if it is not already defined | ||
lookup[value.id] ??= value; | ||
} else if (!Object.keys(lookup).includes(value.id)) { |
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.
This is the only major change, if there is an object { id: 'ubc' }
coming in, we don't want to overwrite anything, and in the initial stages of validation we also don't want to warn. This is a linking action.
const value = validateObjectKeys(input, { optional: AFFILIATION_KEYS }, opts); | ||
const value = validateObjectKeys( | ||
input, | ||
{ optional: AFFILIATION_KEYS, alias: AFFILIATION_ALIASES }, |
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.
Added some affiliation aliases (including to support qmd).
@@ -0,0 +1,6 @@ | |||
--- | |||
'myst-frontmatter': patch |
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.
'myst-frontmatter': patch | |
'myst-frontmatter': minor |
I think we could do this as a minor release for frontmatter.
Removes name/institution check
90b14f0
to
6473064
Compare
We are making the changes to all of the templates, including @dressedfez's. The site templates will also need to be updated before we release, that will happen in the next few hours! |
This adds an affiliation object to frontmatter (instead of affiliation just being list of strings on each author).
Also, validating frontmatter, deduplicates affiliations across authors/pages/projects and normalizes them to a single list, referenced elsewhere by id.