nativescript-vue.org
nativescript-vue.org copied to clipboard
Fixed blog order
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: https://github.com/nativescript-vue/nativescript-vue.org/issues/55
Deploy preview for nativescript-vue ready!
Built with commit 9f5386a022d00df837b7f6c9767fa2f83fad1bce
https://deploy-preview-147--nativescript-vue.netlify.com
@rigor789 Can you take a look?
@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
Weird. I'll get back to the drawing board :D
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
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!
Oh, well, I'm still interested in making this one work but I'll be abandoning it for now.