diff options
author | Manolo Carrasco <manolo@apache.org> | 2015-10-01 07:52:14 +0200 |
---|---|---|
committer | Manolo Carrasco <manolo@apache.org> | 2015-10-01 07:52:14 +0200 |
commit | 3d3811ffa554863c3b68b2f8dcb12d3c995afd8a (patch) | |
tree | 1f704db364f0bb27c75861ae5870ced37274dd37 /tasks/docsite.js | |
parent | 64c9a94a470c47e1d4a457c2cb7814f1f824c34f (diff) | |
download | vaadin-core-3d3811ffa554863c3b68b2f8dcb12d3c995afd8a.tar.gz vaadin-core-3d3811ffa554863c3b68b2f8dcb12d3c995afd8a.zip |
Add source src to meta info, so as website can figure out the github location of each file
Diffstat (limited to 'tasks/docsite.js')
-rw-r--r-- | tasks/docsite.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tasks/docsite.js b/tasks/docsite.js index 7e08169..c31683c 100644 --- a/tasks/docsite.js +++ b/tasks/docsite.js @@ -16,6 +16,7 @@ var version = config.version; var host = config.cdnHost; var permalink = config.permalink; var stagingPath = stagingBasePath + '/' + version; +var modify = require('gulp-modify'); gulp.task('cdn:docsite:bower_components', ['cdn:stage-bower_components'], function() { gutil.log('Copying bower components from ' + stagingPath + ' to ' + docPath + '/bower_components'); @@ -36,8 +37,15 @@ config.components.forEach(function (n) { // Remove bad tags .pipe(replace(/^.*<(!doctype|\/?html|\/?head|\/?body|meta|title).*>.*\n/img, '')) // Uncomment metainfo, and enclose all the example in {% raw %} ... {% endraw %} to avoid liquid conflicts - .pipe(replace(/^.*<!--[ \n]+([\s\S]*?title:[\s\S]*?)[ \n]+-->.*\n([\s\S]*)/img, '---\n$1\n---\n{% raw %}\n$2\n{% endraw %}')) - // Remove the section with table-of-contents + // We use gulp-modify instead of replace in order to handle the github url for this file + .pipe(modify({ + fileModifier: function(file, contents) { + var re = new RegExp(".*/" + n + "/"); + var gh = 'https://github.com/vaadin/' + n + '/edit/master/' + file.path.replace(re, ''); + return contents.replace(/^.*<!--[ \n]+([\s\S]*?title:[\s\S]*?)[ \n]+-->.*\n([\s\S]*)/img, + '---\n$1\nsourceurl: ' + gh + '\n---\n{% raw %}\n$2\n{% endraw %}'); + } + })) .pipe(replace(/^.*<section>[\s\S]*?table-of-contents[\s\S]*?<\/section>.*\n/im, '')) // Add ids to headers, so as site configures permalinks .pipe(replace(/<h(\d+)>(.*)(<\/h\d+>)/img, function($0, $1, $2, $3){ |