Comments (1)
I know this one is 9 months old, so if you've already found a fix my apologies. I've been seeing the same problem, and I believe I'm narrowing in on the issue.
The quick solution is to have your slug (file name) be exclusively lower case.
The longer answer has absorbed a number of hours this evening/morning now, but I believe is traced to the fact that the slug only gets passed through strtolower in Post::expected_source_filename(). I believe that this function doesn't get run on new posts before the hook is called, thus the $slug referenced by the hook isn't in lower case, however as part of the Updater process the function does get called leading to the links on the home page being correct but those available to hooks being incorrect.
There are several different possible solutions:
-
just save your files in all lower case, causing your slug to be in all lower case and this issue to never occur.
-
modify the Post::array_for_template() function to make $slug lowercase:
public function array_for_template()
{
$this->slug = strtolower($this->slug);
...
}
This seems 'hacky' and like its not solving the real issue...
- modify Post::__construct so that $this->slug is set to lowercase at that time, making it no longer necessary to set it to lower case in Post::expected_source_filename():
public function __construct($source_filename, $is_draft = -1 /* auto */)
{
...
if (is_numeric($filename_datestr)) {
...
$this->slug = strtolower(ltrim(substr($filename, 11, -(strlen(Updater::$post_extension))), '-'));
} else {
...
$this->slug = strtolower(substring_before($filename, '.'));
}
}
This seems less 'hacky' to me, but I'm not clear if there was a reason for waiting to make the slug lowercase until Post::expected_source_filename()
- Figure out why its only an issue for the array_for_template() call thats part of the hook process, and not for the normal post updating/creating that gets done for the rest of the blog.
I'm leaning towards option number 3, and after I get some sleep I'll test it further to see if it breaks anything, and possibly submit a pull request with the change to see what Marco thinks (assuming he has time/interest).
from secondcrack.
Related Issues (19)
- Month archives only show a few posts HOT 4
- Post hooks
- Feature Request: Slug override HOT 2
- Pagination HOT 1
- other extension than .txt? HOT 2
- feature: github pages hook? HOT 1
- Post archive may not reorder after post deletion
- Feature request: Process sub folders inside "pages" (and their contents)
- Format change for Tag pages and RSS Feeds HOT 2
- Windows Support HOT 3
- Editing post slugs unreliable
- Support for Scheduled Publishing HOT 1
- Zip Files
- i feel my site is deformed. HOT 1
- License? HOT 2
- Lack of commenting within source code HOT 1
- Posting with bookmarklets HOT 2
- Tag pages should use numbered pagination, not monthly Archives HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from secondcrack.