Add `:path` as a valid permalink component?
- Dominant language
- TypeScript
- Stars
- 41.8k
- Forks
- 41
- PR merge metrics
- No merged PRs in 30d
Description
### Check List
- [X] I have already read [Docs page](https://hexo.io/docs/).
- [X] I have already searched existing issues.
### Feature Request
So this feature request is essentially #5263, but I think it *might* be useful to others as well. I am using Hexo 7.1.1.
How about making `:path` a valid permalink component, just like `:name` where you have the filename of the source?
My current permalink setup is:
```yaml
permalink: :path/:hash/
```
which yields something like `https://example.com/path/to/012345abcdef/`.
I'm no Hexo or JavaScript pro, so to me it doesn't look too complex. All I did to make this setup work is to add a single line:
```diff
--- a/lib/plugins/filter/post_permalink.ts
+++ b/lib/plugins/filter/post_permalink.ts
@@ -26,6 +26,7 @@
id: id || _id,
title: slug,
name: typeof slug === 'string' ? (0, path_1.basename)(slug) : '',
+ path: typeof slug === 'string' ? (0, path_1.dirname)(slug) : '',
post_title: (0, hexo_util_1.slugize)(title, { transform: 1 }),
year: date.format('YYYY'),
month: date.format('MM'),
```
Again, I'm not sure if this will have any negative consequences, just "it works for me." Any ideas?
### Others
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.