diff --git a/extension/model.d.ts b/extension/model.d.ts index dce0b34..acf217f 100644 --- a/extension/model.d.ts +++ b/extension/model.d.ts @@ -31,4 +31,5 @@ export interface IndexBlogData extends IndexData { imgteaser: string; modeDev: boolean; blog: boolean; + subdirectory: string; } diff --git a/extension/model.ts b/extension/model.ts index a0becfc..f522f00 100644 --- a/extension/model.ts +++ b/extension/model.ts @@ -49,4 +49,5 @@ export interface IndexBlogData extends IndexData { modeDev: boolean; // boolean to say if the page is a blog post or not blog: boolean; + subdirectory : string; } diff --git a/extension/read-asciidoctor.js b/extension/read-asciidoctor.js index 282bf84..6bb68d7 100644 --- a/extension/read-asciidoctor.js +++ b/extension/read-asciidoctor.js @@ -38,19 +38,23 @@ function extReadAsciidoc(options) { file.attributes = file.ast.getAttributes(); var filename = file.path.substring(file.path.lastIndexOf("/") + 1, file.path.lastIndexOf(".")); var dir = ''; + var subdirectory = ''; if (options.dirNames && options.dirNames.length > 0) { options.dirNames.forEach(function (dirname) { if (file.path.lastIndexOf(dirname) > 0) { dir = file.path.substring(file.path.lastIndexOf(dirname) + dirname.length, file.path.lastIndexOf("/")); + subdirectory = dirname; } }); } else { if (file.path.lastIndexOf("blog/") > 0) { dir = file.path.substring(file.path.lastIndexOf("blog/") + "blog/".length, file.path.lastIndexOf("/")); + subdirectory = 'blog'; } if (file.path.lastIndexOf("training/") > 0) { dir = file.path.substring(file.path.lastIndexOf("training/") + "training/".length, file.path.lastIndexOf("/")); + subdirectory = 'training'; } } var indexData = { @@ -63,6 +67,7 @@ function extReadAsciidoc(options) { category: file.attributes.category, teaser: file.attributes.teaser, imgteaser: file.attributes.imgteaser, + subdirectory: subdirectory, modeDev: options.modeDev, blog: true, dir: dir, @@ -85,7 +90,7 @@ function extReadAsciidoc(options) { imgteaser: function () { return indexData.imgteaser; }, status: function () { return file.attributes.status; }, modedev: function () { return indexData.modeDev; }, - canonicalUrl: function () { return "blog/" + dir + "/" + filename + ".html"; } + canonicalUrl: function () { return subdirectory + "/" + dir + "/" + filename + ".html"; } }; if (file.attributes.status !== 'draft') { file.indexData = indexData; diff --git a/extension/read-asciidoctor.ts b/extension/read-asciidoctor.ts index de70e79..e6e9e25 100644 --- a/extension/read-asciidoctor.ts +++ b/extension/read-asciidoctor.ts @@ -48,19 +48,23 @@ export function extReadAsciidoc(options: Options): Transform { const filename = file.path.substring(file.path.lastIndexOf("/") + 1, file.path.lastIndexOf(".")); let dir = ''; + let subdirectory = ''; if(options.dirNames && options.dirNames.length > 0) { options.dirNames.forEach(dirname => { if (file.path.lastIndexOf(dirname) > 0) { dir = file.path.substring(file.path.lastIndexOf(dirname) + dirname.length, file.path.lastIndexOf("/")); + subdirectory = dirname; } }) } else { if (file.path.lastIndexOf("blog/") > 0) { dir = file.path.substring(file.path.lastIndexOf("blog/") + "blog/".length, file.path.lastIndexOf("/")); + subdirectory = 'blog'; } if (file.path.lastIndexOf("training/") > 0) { dir = file.path.substring(file.path.lastIndexOf("training/") + "training/".length, file.path.lastIndexOf("/")); + subdirectory = 'training'; } } @@ -74,6 +78,7 @@ export function extReadAsciidoc(options: Options): Transform { category: file.attributes.category, teaser: file.attributes.teaser, imgteaser: file.attributes.imgteaser, + subdirectory: subdirectory, modeDev: options.modeDev, blog: true, dir: dir, @@ -97,7 +102,7 @@ export function extReadAsciidoc(options: Options): Transform { imgteaser: () => indexData.imgteaser, status: () => file.attributes.status, modedev: () => indexData.modeDev, - canonicalUrl: () => `blog/${dir}/${filename}.html` + canonicalUrl: () => `${subdirectory}/${dir}/${filename}.html` }; if (file.attributes.status !== 'draft') {