Skip to content
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

Merged
merged 10 commits into from
Aug 10, 2023
Merged

Conversation

fwkoch
Copy link
Collaborator

@fwkoch fwkoch commented Aug 8, 2023

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.

frontmatter.affiliations
?.filter((aff) => aff.id && !aff.collaboration)
.map((aff, index) => {
return { value: aff, ...indexAndLetter(index) };
Copy link
Collaborator Author

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.

Copy link
Collaborator

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?

Copy link
Contributor

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?

Copy link
Collaborator

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!

Copy link
Collaborator

@rowanc1 rowanc1 left a 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.

Comment on lines 261 to 273
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)) {
Copy link
Collaborator

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 },
Copy link
Collaborator

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).

packages/myst-frontmatter/src/frontmatter/validators.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,6 @@
---
'myst-frontmatter': patch
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'myst-frontmatter': patch
'myst-frontmatter': minor

I think we could do this as a minor release for frontmatter.

@rowanc1
Copy link
Collaborator

rowanc1 commented Aug 10, 2023

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants