-
Notifications
You must be signed in to change notification settings - Fork 394
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
Let sidebar uppercase more than dvc
in labels made from slugs
#3602
Changes from 1 commit
2090608
b26d68b
6260a23
12ecaf7
d9fe1c0
15a3be3
7658819
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,12 +23,22 @@ | |
const { titleCase } = require('title-case') | ||
const sidebar = require('../../../sidebar') | ||
|
||
const uppercaseKeywords = ['dvc', 'cml', 'api', 'ml'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jorgeorpinel, these are the keywords that will be uppercased. Does the list look good? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's add MLEM, LDB There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. List is now |
||
const PATH_ROOT = '/doc' | ||
const FILE_ROOT = '/docs/' | ||
const FILE_EXTENSION = '.md' | ||
|
||
function dvcTitleCase(slug) { | ||
return titleCase(slug.replace(/dvc/g, 'DVC').replace(/-/g, ' ')) | ||
function uppercaseSlugKeywords(slug) { | ||
julieg18 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let newSlug = slug | ||
uppercaseKeywords.forEach(word => { | ||
julieg18 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const regex = new RegExp(String.raw`${word}`, 'g') | ||
newSlug = newSlug.replace(regex, word.toUpperCase()) | ||
}) | ||
return newSlug | ||
} | ||
|
||
function slugTitleCase(slug) { | ||
return titleCase(uppercaseSlugKeywords(slug).replace(/-/g, ' ')) | ||
} | ||
|
||
function validateRawItem({ slug, source, children, type, url }) { | ||
|
@@ -113,7 +123,7 @@ function normalizeItem({ rawItem, parentPath, resultRef, prevRef }) { | |
return { | ||
path: relativePath ? `${PATH_ROOT}/${relativePath}` : PATH_ROOT, | ||
source: source === false ? false : sourcePath, | ||
label: label ? label : dvcTitleCase(slug), | ||
label: label ? label : slugTitleCase(slug), | ||
tutorials: tutorials || {}, | ||
prev, | ||
next: undefined, | ||
|
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.
Since the sidebar code automatically uppercases
ml
andapi
, these two labels can be taken off.