mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-07 22:37:28 +08:00
Added SiteMap generation to the documentation
This commit is contained in:
31
docs/src/SiteMap.js
Normal file
31
docs/src/SiteMap.js
Normal file
@@ -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, '"');
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,8 @@ require.paths.push('lib');
|
||||
var reader = require('reader.js'),
|
||||
ngdoc = require('ngdoc.js'),
|
||||
writer = require('writer.js'),
|
||||
callback = require('callback.js');
|
||||
callback = require('callback.js'),
|
||||
SiteMap = require('SiteMap.js').SiteMap;
|
||||
|
||||
var docs = [];
|
||||
var start;
|
||||
@@ -30,6 +31,8 @@ var writes = callback.chain(function(){
|
||||
writer.copy('doc_widgets.css', writes.waitFor());
|
||||
writer.copy('docs-scenario.html', writes.waitFor());
|
||||
writer.output('docs-scenario.js', ngdoc.scenarios(docs), writes.waitFor());
|
||||
writer.output('sitemap.xml', new SiteMap(docs).render(), writes.waitFor());
|
||||
writer.output('robots.txt', 'Sitemap: http://docs.angularjs.org/sitemap.xml\n', writes.waitFor());
|
||||
writer.copy('syntaxhighlighter/shBrushJScript.js', writes.waitFor());
|
||||
writer.copy('syntaxhighlighter/shBrushXml.js', writes.waitFor());
|
||||
writer.copy('syntaxhighlighter/shCore.css', writes.waitFor());
|
||||
|
||||
Reference in New Issue
Block a user