Skip to content

Instantly share code, notes, and snippets.

@edrex
Created November 7, 2013 08:43
Show Gist options
  • Save edrex/7351236 to your computer and use it in GitHub Desktop.
Save edrex/7351236 to your computer and use it in GitHub Desktop.
Harp sitemap.xml in Jade
doctype xml
- function merge(a,b,pre){for (var f in b) { a[f] = b[f]}; return a}
- function prefix(a,pre){var r={}; for (var f in a) { r[pre+f] = a[f]}; return r}
- function subdirs(b){var r={}; for (var i in b) {if (i !== 'data' && i !== 'contents') r[i]=b[i]}; return r;}
- function all_posts(b,pre){var r=prefix(b.data,pre); for(var s in subdirs(b)){merge(r, all_posts(b[s],pre+s+'/'))}; return r}
urlset(xmlns='http://www.sitemaps.org/schemas/sitemap/0.9')
each val, key in all_posts(public, '/')
url
loc #{key}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment