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 property is not correct when using directory and index.md approach

See original GitHub issue

Version

@nuxt/content: 1.6.0 nuxt: 2.14.1

Reproduction Link

https://codesandbox.io/s/dank-paper-djlm0?file=/content/a-new-entry/index.md

Steps to reproduce

Create two content files

  • one with a unique name at the top level in the content directory
  • one in a subdirectory, and name it index.md

Start the application and check the content. Supply the file name or the directory name as the slug in await $content(slug)

What is Expected?

the slug property on the returned post is the same as what had to be supplied in order to fetch it

What is actually happening?

the slug property is correct for file names, but is being returned as ‘index’ for directory based content ie. the .md file name not the actual slug name

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
davydnorriscommented, Aug 17, 2020

OK so there’s maybe two things here.

I now see that you supply a path to $content, which makes sense.

But a slug is defined as “the unique identifying part of a web address, typically at the end of the URL”, which is not necessarily the file name. In the case of this issue, it’s the final part of the URL, which is either the file name (minus .md) in the case of discrete files, or the name of the enclosing directory in the case of an index.md.

Returning ‘index’ as the slug every single time is not useful, and not correct from an SEO and web point of view.

0reactions
benjamincanaccommented, Dec 2, 2020

This behaviour will not be changed in the current version as there is no simple way, see https://github.com/nuxt/content/pull/435#issuecomment-683702018.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docs Introduction - Docusaurus
The docs feature provides users with a way to organize Markdown files in a hierarchical format.
Read more >
Frequently Asked Questions - Read the Docs
Frequently Asked Questions¶. My project isn't building correctly¶. First, you should check out the Builds tab of your project. That records all of...
Read more >
How to access resources from pages within a branch bundle
This method works fine for leaf bundles, but fails to work for pages located in the root directory of a branch bundle.
Read more >
Permalinks — Eleventy
You may not be using HTML for that page in 20 years time, but you might want today's links to it to ......
Read more >
Routing • Docs • SvelteKit
Each route directory contains one or more route files, which can be identified ... src/routes/blog/[slug]/+page.svelte ... throw error (404, 'Not found');.
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