-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
feat(content-docs, content-blog): global tags list file & better validation #6025
Conversation
This comment has been minimized.
This comment has been minimized.
- Tests missing yet - Logic is not 100% as Josh-Cena asked for (its too complex for me tbh) - Some code duplicates can be refactored - Docs missing?
✔️ [V2] 🔨 Explore the source changes: b611ce1 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/61a288bbe9c51b0007be8fda 😎 Browse the preview: https://deploy-preview-6025--docusaurus-2.netlify.app |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-6025--docusaurus-2.netlify.app/ |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Hey, I'll work on this for the coming week and hopefully make it ready for merge |
Signed-off-by: Joshua Chen <sidachen2003@gmail.com>
After discussion with @Josh-Cena I set this to |
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.
Thanks, that looks like a great first working version 👍
I left a few comments and a few changes that we should probably discuss
The PR mention docs but I don't see any impl for the docs plugin yet: it's probably better to do the impl in both plugins at once for consistency.
Also need some documentation :)
return Joi.attempt(content, TagsMapSchema); | ||
} | ||
|
||
export async function getTagsMap(params: { |
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.
shouldn't this be in "utils" if we want it for docs too?
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't fine. It's a very lightweight wrapper around a utils function anyways.
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 think I meant we'd need this in the docs plugin too?
return { | ||
label: tagString, | ||
permalink: kebabCase(tagString), | ||
}; | ||
} | ||
|
||
function normalizeTagObject(tag: Partial<Tag>) { | ||
return { | ||
label: tag.label!, |
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.
in which case there's no label here? maybe the type is wrong?
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.
Yeah, the label is the only required value. I just don't feel like it's useful to override one key to required🤦♂️
|
||
export type Tag = { | ||
label: string; | ||
permalink: string; | ||
}; | ||
|
||
export type FrontMatterTag = string | Tag; | ||
export type FrontMatterTag = string | Partial<Tag>; | ||
export type TagsMap = Record<string, Partial<Tag>>; |
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.
IMHO the Tag object shouldn't be partial.
Maybe we should normalize the tagsMap on load so that referenced tags contain at least a label
Maybe create a type like "TagConfig" ?
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.
The problem is that we may add more stuff in the future like description, permalink, etc. I feel like it's valuable to make it remain partial, because maybe not everything makes sense to have a default?
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.
@Josh-Cena I don't imagine any case where a tag without label make sense.
At the end of the day, we must display that tag somewhere in the UI, so there should always be at least a label
@@ -4,7 +4,7 @@ author: Christine Abernathy | |||
authorURL: http://twitter.com/abernathyca | |||
authorImageURL: https://github.com/caabernathy.png | |||
authorTwitter: abernathyca | |||
tags: [profilo, adoption] | |||
tags: [{label: profilo}, adoption] |
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.
do we really want to enable such syntax?
IMHO the ability to pass a permalink inline (and any other shred config that we might introduce later) does not make much sense as it leads to potential non-deterministic behavior when 2 tags are using 2 different inline configs due to bad copy-pasting.
IMHO we should deprecate (or breaking change) the usage of permalink
and just support a simple array: (Label | Key)[]
I know that we support inline blog authors with config, but unlike inline authors, tags always have a dedicated page (inline or not) so we probably always force enforce a unique tag config here.
@slorber The current design is like: there are two modes, I would call them "lax mode" and "strict mode". If there isn't a However, I'd like to retain the ability to have inline tags in case it's not worth to declare a special key for this, maybe because the tag will only ever be used once. If you don't think this feature is worth keeping I'm fine to remove it, but then we would have a too bloated |
I don't like this idea, particularly because 2 inline tags with the same key can have conflicting data I'd rather be strict by default but fail-safe: emit a warning for tags not found in the yml file, and convert them to Unlike blog posts and inline authors, tags always have a page with a permalink and SEO data. It's fine for a blog post to have the same author twice with different descriptions, maybe because the role or image of the author is updated over time and it's a snapshot. I don't think it's the case for tags where you'd rather be consistent. Reconciling/merging data for 2 similar inline tags seems risky and non-deterministic. You may ask: what if we later introduce a page for each blog author => Similarly, I think we'll only create pages for declared authors, not inline ones |
Addresses #5913
Motivation
#5913
Have you read the Contributing Guidelines on pull requests?
Yes.
Test Plan