diff options
| author | Misko Hevery | 2011-01-24 13:33:47 -0800 | 
|---|---|---|
| committer | Misko Hevery | 2011-01-24 14:23:51 -0800 | 
| commit | bf03eb007c31bec4ea9f2ca8a947f9833bb348c9 (patch) | |
| tree | 6bf60a2d3794cda0fffdb8db9e4ea7e0ff84fb58 /docs/src/SiteMap.js | |
| parent | c2f2587a79aeb77aad66f081cf924a79348a698e (diff) | |
| download | angular.js-bf03eb007c31bec4ea9f2ca8a947f9833bb348c9.tar.bz2 | |
Added SiteMap generation to the documentation
Diffstat (limited to 'docs/src/SiteMap.js')
| -rw-r--r-- | docs/src/SiteMap.js | 31 | 
1 files changed, 31 insertions, 0 deletions
| diff --git a/docs/src/SiteMap.js b/docs/src/SiteMap.js new file mode 100644 index 00000000..f6f909e9 --- /dev/null +++ b/docs/src/SiteMap.js @@ -0,0 +1,31 @@ +exports.SiteMap = SiteMap; + +/** + * @see http://www.sitemaps.org/protocol.php + * + * @param docs + * @returns {SiteMap} + */ +function SiteMap(docs){ +  this.render = function(){ +    var map = []; +    map.push('<?xml version="1.0" encoding="UTF-8"?>'); +    map.push('<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'); +    docs.forEach(function(doc){ +      map.push(' <url><loc>http://docs.angularjs.org/#!' + +          encode(doc.name) + '</loc><changefreq>weekly</changefreq></url>'); +    }); +    map.push('</sitemapindex>'); +    map.push(''); +    return map.join('\n'); +  }; + +  function encode(text){ +    return text +      .replace(/&/mg, '&') +      .replace(/</mg, '<') +      .replace(/>/mg, '>') +      .replace(/'/mg, ''') +      .replace(/"/mg, '"'); +  } +} | 
