SnowdogApps / vuepress-plugin-pdf-export

Vuepress plugin for exporting as PDF without system wide dependencies suitable for headless environments
MIT License
29 stars 7 forks source link

Example for sorter function #5

Closed Beluk closed 4 years ago

Beluk commented 4 years ago

Can you please provide an example how to use the sorter function?

Igloczek commented 4 years ago

It's a vanilla JS array sort function

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort

Beluk commented 4 years ago

Thank you. For someone else interested in this topic i used it to bring the landing page to the first side of the pdf:

['@snowdog/vuepress-plugin-pdf-export', {
         sorter: function(a, b){  if (a.relativePath == "index.md") return -1; if (b.relativePath == "index.md") return 1;
           return a.attr > b.attr ? -1: 1;}
}]