Skip to content

Commit fce0b80

Browse files
Merge branch 'master' of github.com:tomcollins/json-schema-static-docs
2 parents 7aaf20b + 0d3df8b commit fce0b80

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

lib/json-schema-static-docs.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ const defaultOptions = {
1313
outputPath: 'docs',
1414
templatePath: path.join(__dirname, '../templates'),
1515
resolve: {},
16-
additionalDataSources: {}
16+
additionalDataSources: {},
17+
linkBasePath: './'
1718
};
1819

1920
var JsonSchameStaticDocs = function(options){
@@ -59,7 +60,7 @@ JsonSchameStaticDocs.prototype.generate = async function() {
5960
}
6061
});
6162

62-
let renderer = new Renderer(this._options.templatePath);
63+
let renderer = new Renderer(this._options.templatePath, this._options.linkBasePath);
6364
await renderer.setup();
6465

6566
await Promise.all(mergedSchemas.map(async mergedSchema => {

lib/renderer-markdown.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const _ = require('lodash');
66

77
const readFile = util.promisify(fs.readFile);
88

9+
let refLinkBasePath = '';
10+
911
const toTypeLinkLabel = label => {
1012
label = label || "";
1113
label = label.substr(0, 1).toUpperCase() + label.substr(1);
@@ -23,7 +25,7 @@ const refToLink = (ref, label) => {
2325
// @todo this should not exist in this package
2426
// maybe pass in as a link resolver function ?
2527
// return '[' + label +'](./' +filename + '.html)';
26-
return '<a href="./' +filename + '.html">' + label +'</a>';
28+
return '<a href="' + refLinkBasePath + filename + '.html">' + label +'</a>';
2729
};
2830

2931
const jsonSchemaType = property => {
@@ -159,8 +161,12 @@ Handlebars.registerHelper('propertyTypeRow', function(property) {
159161
return new Handlebars.SafeString(html);
160162
});
161163

162-
var RendererMarkdown = function(templatePath) {
164+
var RendererMarkdown = function(templatePath, linkBasePath) {
163165
this.templatePath = templatePath;
166+
if (linkBasePath == undefined) {
167+
linkBasePath = './';
168+
}
169+
refLinkBasePath = linkBasePath;
164170
}
165171

166172
RendererMarkdown.prototype.setup = async function() {

lib/renderer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
let RendererMarkdown = require('./renderer-markdown');
22

3-
function Renderer(templatePath){
4-
this.renderer = new RendererMarkdown(templatePath);
3+
function Renderer(templatePath, linkBasePath){
4+
this.renderer = new RendererMarkdown(templatePath, linkBasePath);
55
};
66

77
Renderer.prototype.setup = async function() {

0 commit comments

Comments
 (0)