Open dreh23 opened 9 years ago
This is more complicated than I anticipated. I got a something running with grunt-contrib-rewrite, but it's more complicated. The example below kind of works. But I can't get the regexp working so we need an entry for every article. Kind of ugly:
string = "/docs/one_of_the_resources/one-of-the-resources.html";
console.log(string.match(/\/[^/]+$/)[0]);
// => one-of-the-resources.html
And the Gruntfile would look like this:
var rewriteRulesSnippet = require('grunt-connect-rewrite/lib/utils').rewriteRequest;
.....
connect: {
rules: [
{from: '/documentation.html', to: '/docs/documentation/documentation.html'}
],
server: {
options: {
port: port,
base: './dist',
livereload: 35005,
open: true,
middleware: function (connect, options) {
var middlewares = [];
// RewriteRules support
middlewares.push(rewriteRulesSnippet);
if (!Array.isArray(options.base)) {
options.base = [options.base];
}
var directory = options.directory || options.base[options.base.length - 1];
options.base.forEach(function (base) {
// Serve static files.
middlewares.push(connect.static(base));
});
// Make directory browse-able.
//middlewares.push(connect.directory(directory));
return middlewares;
}
}
}
},
....
jshint: {
globals: {
....
require: false,
....
}
},
....
grunt.registerTask( 'serve', [ 'configureRewriteRules', 'connect:server', 'watch'] );
I would like to postpone this to another milestone.
From @mrchristian on May 31, 2015 21:7
hi
currently URLs have duplicate names in URLs
docs/book_liberation_manifesto/Book_Liberation_Manifesto.html
either we rename HTML files index.html or we have serving remove directory name above
S
Copied from original issue: hybrid-publishing-lab/hybrid-publishing-research#31