Sort OPML feeds list + link to the HTML version by default
This commit is contained in:
@@ -10,7 +10,8 @@
|
||||
"docker:build": "pnpm run build && docker build -t ${DOCKER_REGISTRY}/garrettmills/www-ssg .",
|
||||
"docker:run": "pnpm run docker:build && docker run --rm -p 8080:80 ${DOCKER_REGISTRY}/garrettmills/www-ssg",
|
||||
"docker:sh": "pnpm run docker:build && docker run --rm -it -p 8080:80 ${DOCKER_REGISTRY}/garrettmills/www-ssg sh",
|
||||
"docker:push": "docker push ${DOCKER_REGISTRY}/garrettmills/www-ssg"
|
||||
"docker:push": "docker push ${DOCKER_REGISTRY}/garrettmills/www-ssg",
|
||||
"deploy": "pnpm run docker:build && pnpm run docker:push && kubectl rollout restart deployment garrettmills-dev"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
import fs from "fs";
|
||||
import * as opml from "opml";
|
||||
|
||||
const sortArrayOfObjectsByProperty = (arr, prop, desc=false) => {
|
||||
const direction = desc ? -1 : 1
|
||||
return arr.sort((a, b) => {
|
||||
if ( a[prop] < b[prop] ) return -1 * direction
|
||||
if ( a[prop] > b[prop] ) return 1 * direction
|
||||
return 0
|
||||
})
|
||||
}
|
||||
|
||||
export const setupBlogCollections = eleventyConfig => {
|
||||
eleventyConfig.addCollection("blogByYear", api => {
|
||||
const postsByYear = {}
|
||||
@@ -45,6 +54,9 @@ export const setupBlogCollections = eleventyConfig => {
|
||||
opml.parse(xml, (err, doc) => err ? rej(err) : res(doc))
|
||||
})
|
||||
|
||||
return parsed.opml.body.subs
|
||||
let subs = parsed.opml.body.subs
|
||||
subs = sortArrayOfObjectsByProperty(subs, 'title')
|
||||
subs.forEach(cat => cat.subs = sortArrayOfObjectsByProperty(cat.subs, 'title'))
|
||||
return subs
|
||||
})
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ This list is also available in the standard <a href="/assets/rss_opml.xml" downl
|
||||
{% endif %}
|
||||
<ul>
|
||||
{% for sub in cat.subs %}
|
||||
<li><a href="{{ sub.xmlUrl }}" download>{{ sub.title }}</a></li>
|
||||
<li><a href="{{ sub.htmlUrl }}" download>{{ sub.title }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user