Skip to content

Instantly share code, notes, and snippets.

@ajmalafif
Forked from jorgepedret/sitemap.xml.jade
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save ajmalafif/9f2d60baa459670fd43b to your computer and use it in GitHub Desktop.

Select an option

Save ajmalafif/9f2d60baa459670fd43b to your computer and use it in GitHub Desktop.
- var paths = [], files = []; function recursiveTree(obj) { if (typeof obj == "object" && !obj.length) { for (item in obj) { if (item === "contents") { recursiveTree(obj[item]); } else if (item != "data") { paths.push(item); recursiveTree(obj[item]); paths.splice(paths.length-1, 1); } } } else if (typeof obj == "object") { for (i in obj) { var file = obj[i]; if (/(\.html$)/.test(file)) { paths.push(file); files.push("/" + paths.join("/")); paths.splice(paths.length-1, 1); } } } }; recursiveTree(public);
xml
urlset(xmlns="http://www.sitemaps.org/schemas/sitemap/0.9")
- for(i in files) {
url
loc= files[i]
priority 0.5
- }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment