question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Slug should *just* be the name

See original GitHub issue

At the moment, in the front-matter we have that the slug is a whole path. For example Web/HTML/Element/video when it just needs to, for example:

slug: video

One disadvantage with having the whole path in there is that if you need to rename a slug, you now need to git edit every single index.html that exists below. Another disadvantage is that it’s a foot-gun. You might accidentally edit from slug: Web/HTML/Element/video to slug: We/HTML/Element/video without really noticing.

Lets make the importer just put slug: ${basename(document.slug)) in there. And in the Yari code, we can no longer make the url be ${locale}/docs/${slug} but it needs to become based on looping over the path and doing a Document.findByUrl(...) for each forward-slash.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
peterbecommented, Jan 29, 2021

My recommendation is that we start gently. You start by writing a piece of code where we’re currently extracting the slug from the front-matter and make it smart. Something like this:

-const slug = metadata.slug;
+let slug = metadata.slug || getThisFolderName()
+if (!slug.contains('/')) {
+   // It's one of those fancy new ones that just contain a single word
+   slug = `${getParentSlug()}/${slug}`;
+}

That way, at your convenience you can pick an index.html in mdn/content and either remove the slug or if it needs casing you rename it…

-slug: Web/HTML/Element
+slug: Element
0reactions
Ryuno-Kicommented, Jan 29, 2021

Okay, so what would be needed in code and content next?

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Are Slugs And How To Name Them In WordPress (2021)
In this section, we will teach you how to name your slugs to optimize them for SEO and readability. This section will be...
Read more >
What is a slug? - NationBuilder HOWTOs
A slug is the “name” of your NationBuilder site. For example, my site is awesome.nationbuilder.com - so “awesome” is my slug. Slugs are...
Read more >
WordPress Slugs: What They Are & How to Change Them
A slug is a part of a permalink. More specifically, it's the name of the page or post at the end of the...
Read more >
What is a slug in WordPress (and bad practices you should ...
The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens. It goes...
Read more >
What is a slug? - Awards Management Software
What is a slug? Well, the name “slug” comes from web publishing, and refers usually to part of a URL which identifies a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found