Skip to content

Fixed blog order #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: v2
Choose a base branch
from
Open

Conversation

ikoevska
Copy link
Contributor

@ikoevska ikoevska commented May 27, 2018

What I did:

  • ordered the collection by the custom 'order'
  • extended the functionality of the custom order plugin to capture the date properly, not only the first number sequence in the file name
  • extended the functionality of the custom order plugin to the blog folder as well

Attempts to solve: #55

@nativescript-vue-bot
Copy link

nativescript-vue-bot commented May 27, 2018

Deploy preview for nativescript-vue ready!

Built with commit 9f5386a

https://deploy-preview-147--nativescript-vue.netlify.com

@ikoevska ikoevska changed the title Changed regex that captures date Fixed blog order May 27, 2018
@ikoevska
Copy link
Contributor Author

ikoevska commented Jun 6, 2018

@rigor789 Can you take a look?

@rigor789
Copy link
Member

rigor789 commented Jun 6, 2018

@ikoevska just checked but I'm not sure if this solves the problem (which seems to only happen sometimes), from a quick test

const t = "2018-02-12-nativescript-vue-1.0-and-a-new-site.md"
const a = t.match(/^(\d+)-/)
const b = t.match(/^((\d+)-)+/)

console.log(a[1]) // 2018
console.log(b[1]) // 12-

I don't think the order will be accurate when it's set to 12-

Maybe we could convert the date to a timestamp, which can then be sorted/ordered

@ikoevska
Copy link
Contributor Author

ikoevska commented Jun 6, 2018

Weird. I'll get back to the drawing board :D

@ikoevska
Copy link
Contributor Author

ikoevska commented Jun 9, 2018

Hey @rigor789 second attempt :) This time it seems like it would work.

Turned out res[0] is what got the right match that we needed. I am stripping the hyphens from it and passing it along.

const t = "2018-02-12-nativescript-vue-1.0-and-a-new-site.md"
const a = t.match(/^(\d+)-/)
const b = t.match(/^((\d+)-)+/)

console.log(a[0].replace(/-/g, '')) //2018
console.log(b[0].replace(/-/g, '')) //20180212
const y = "03-some-ordered-file-name.md"
const c = y.match(/^(\d+)-/)
const d = y.match(/^((\d+)-)+/)

console.log(c[0].replace(/-/g, '')) //03
console.log(d[0].replace(/-/g, '')) //03

Use non-capturing groups because we don't need to manipulate the groups separately
@rigor789
Copy link
Member

rigor789 commented Jun 9, 2018

This looks good - and I think it should be working, but for some reason the order is still wrong in the build :/

https://deploy-preview-147--nativescript-vue.netlify.com/blog/using-fonticons/ (April 07)
is before
https://deploy-preview-147--nativescript-vue.netlify.com/blog/using-parse-in-nativescript-vue/ (February 28)

I can dig a little deeper next week, don't waste any more time on this - could be a bug in metalsmith-collections!

@ikoevska
Copy link
Contributor Author

Oh, well, I'm still interested in making this one work but I'll be abandoning it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants