nativescript-vue.org icon indicating copy to clipboard operation
nativescript-vue.org copied to clipboard

Fixed blog order

Open ikoevska opened this issue 7 years ago • 7 comments
trafficstars

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

ikoevska avatar May 27 '18 17:05 ikoevska

Deploy preview for nativescript-vue ready!

Built with commit 9f5386a022d00df837b7f6c9767fa2f83fad1bce

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

nativescript-vue-bot avatar May 27 '18 18:05 nativescript-vue-bot

@rigor789 Can you take a look?

ikoevska avatar Jun 06 '18 11:06 ikoevska

@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

rigor789 avatar Jun 06 '18 11:06 rigor789

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

ikoevska avatar Jun 06 '18 11:06 ikoevska

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

ikoevska avatar Jun 09 '18 12:06 ikoevska

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!

rigor789 avatar Jun 09 '18 13:06 rigor789

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

ikoevska avatar Jun 25 '18 10:06 ikoevska