match posts on year/month too
Shouldn't assume that slugs will be globally unique, this enforces month-local uniqueness instead
This commit is contained in:
parent
e22f52b06d
commit
b9fe8c7f38
1 changed files with 9 additions and 1 deletions
10
src/Post.js
10
src/Post.js
|
|
@ -24,12 +24,20 @@ class Post extends Component {
|
||||||
.then((blob) => {
|
.then((blob) => {
|
||||||
let found = false;
|
let found = false;
|
||||||
for (let post of blob.posts) {
|
for (let post of blob.posts) {
|
||||||
|
let date = new Date(post.date);
|
||||||
|
let year = date.getUTCFullYear();
|
||||||
|
let month = date.getUTCMonth() + 1;
|
||||||
|
|
||||||
let slug = post.slug;
|
let slug = post.slug;
|
||||||
if (!slug) {
|
if (!slug) {
|
||||||
slug = slugify(post.title);
|
slug = slugify(post.title);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slug === this.params.slug) {
|
if (
|
||||||
|
slug === this.params.slug
|
||||||
|
&& year === Number(this.params.year)
|
||||||
|
&& month === Number(this.params.month)
|
||||||
|
) {
|
||||||
this.setState({post: post})
|
this.setState({post: post})
|
||||||
found = true;
|
found = true;
|
||||||
break
|
break
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue