Option to use path in slug generation
See original GitHub issueIs your feature request related to a problem? Please describe.
When creating articles, sometimes they might have the title but since they are placed in different subdirectories under content
, the filesystem will naturally not throw a name conflict error. However, when the url is directly called, the system will select only the latest one. I’d like to ensure that subdirectories or tags can be added to the slug generation to enforce uniqueness
content
| -- django
|-- basics.md --> http://localhost:3000/basics
| -- java
|-- basics.md --> http://localhost:3000/basics
Describe the solution you’d like
The slug generation can allow an option to use the path to the file as a part of the slug or each subfolder can have a default config.json that can be used to store the alias to be used instead of the complete directory path.
The options
With subdirectory as slug
content
| -- django
|-- basics.md --> http://localhost:3000/django/basics
|-- advanced
|-- orm_issues --> http://localhost:3000/django/advanced/orm_issues
| -- java
|-- basics.md --> http://localhost:3000/java/basics
|-- advanced
|-- orm_issues.md --> http://localhost:3000/java/advanced/orm_issues
With alias config
content
| -- django
|-- basics.md --> http://localhost:3000/django/basics
|-- advanced
|-- orm_issues --> http://localhost:3000/django/orm_issues
|-- config.json ({"alias":"django"})
| -- java
|-- basics.md --> http://localhost:3000/basics
|-- advanced
|-- orm_issues.md --> http://localhost:3000/advanced_java/orm_issues
|-- config.json ({"alias":"advanced_java"})
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
URLs and Slugs | Documentation | Lektor Static Content ...
Slugs Containing Slashes The parent paths are always added to it. So once a page has a parent page /foo its URL path...
Read more >What the Heck are Content Slugs and How Do I Use Them?
Here are a few examples for some of the popular static site generator options and how they handle slugs and permalinks.
Read more >Django Slug Tutorial | LearnDjango.com
How to add URL slugs to a Django project. ... Let's take the easy approach of setting null=True for now. So type 2...
Read more >type = 'slug' — TCA Reference 10.4 documentation
Within TYPO3, a slug is always part of the URL "path" - it does not contain ... Sanitation and Validation configuration options apply...
Read more >Slug - Sanity.io
Maximum number of characters the slug may contain when generating it from a ... your own slugify function, or manually enter your slug...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@VaZark I don’t think a PR is necessary, as the
deep
flag already provides you with what you need. The issue you’re facing is likely with your folder structure.For example, you could have a folder structure like this:
And then, in your
/pages/_topic/_slug.vue
file:This will return the content at that relative path in your content folder.
Edit: For the
advanced
directory, you will need to account for that in your folder structure, so I’ve edited my comment and you should be able to work out how to do it from there.You can easily do this:
_.vue
page. Here, fetch all your posts inside Content folder usingwhere
option withpath
query. You may use regex too for better querying, if your_.vue
page is inside some other page. Of course, you need to choose{deep:true}
too_.vue
page.where
option withdir
query.dir
. Then, on the current post, this post’s children will show up based on v-if and dropdown.