mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
add dedicated markdown path fixups
This commit is contained in:
parent
bb9bbbc5f2
commit
92e705f0db
@ -15,28 +15,49 @@
|
|||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
/**
|
||||||
|
* construct a url for the provided logical target path, taking into account
|
||||||
|
* the current document location, port, and logical element path.
|
||||||
|
* When in dev mode as indicated by port 3003,
|
||||||
|
* this auto converts service urls to point at a backend running on the same
|
||||||
|
* host, such that the statically served content comes from the app dev
|
||||||
|
* server, and service endpoints come from the service layer on a different port.
|
||||||
|
*/
|
||||||
url(document, context, path) {
|
url(document, context, path) {
|
||||||
console.log("isDev=" + context.isDev)
|
// console.log("isDev=" + context.isDev)
|
||||||
console.log("document.location=" + JSON.stringify(document.location, null, 2))
|
// console.log("document.location=" + JSON.stringify(document.location, null, 2))
|
||||||
|
|
||||||
let origin = document.location.origin;
|
let origin = document.location.origin;
|
||||||
let base = origin;
|
let base = origin;
|
||||||
|
base = origin.replace(":3003", ":12345")
|
||||||
|
|
||||||
if (origin.includes(":3003")) {
|
// console.log("base=" + base + ", path=" + path);
|
||||||
base = origin.replace(":3003", ":12345")
|
|
||||||
}
|
|
||||||
console.log("base=" + base);
|
|
||||||
let url = base + path;
|
let url = base + path;
|
||||||
console.log("url=" + url);
|
// console.log("url=" + url);
|
||||||
return url;
|
return url;
|
||||||
},
|
},
|
||||||
localize(body, baseurl) {
|
localize(body, docurl) {
|
||||||
// console.log("localize([body],baseurl='" + baseurl + "'")
|
let localized = body;
|
||||||
// const regex = /\[([^/][^]]+)]/;
|
// console.log("localizing " + details.path)
|
||||||
// let remaining = body;
|
let offset = docurl.lastIndexOf("/")
|
||||||
//
|
let baseurl = docurl.slice(0, offset + 1)
|
||||||
// while (remaining.)
|
|
||||||
//
|
let replacer = function (match, p1, p2, p3, groups) {
|
||||||
return body;
|
let replacement = "[" + p1 + "](" + baseurl + p2 + p3 + ")"
|
||||||
|
|
||||||
|
// console.log("docurl:" + docurl)
|
||||||
|
// console.log("matched:" + match)
|
||||||
|
// console.log("baseurl:'" + baseurl + "'")
|
||||||
|
// console.log("endpoints.baseUrlFor(document.location,isDev)'" + p1 + "'")
|
||||||
|
// console.log("p2:'" + p2 + "'")
|
||||||
|
// console.log("replacement:'"+replacement+"'")
|
||||||
|
|
||||||
|
return replacement;
|
||||||
|
}
|
||||||
|
localized = localized.replace(/\[([a-zA-Z0-9 ]+)]\(([-._a-zA-Z0-9]+)( [=x0-9]+)?\)/g, replacer)
|
||||||
|
if (body !== localized) {
|
||||||
|
// console.log("rewrote:\n" + localized)
|
||||||
|
}
|
||||||
|
return localized;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,8 +174,8 @@ export const actions = {
|
|||||||
let weight = ((mdMeta.attributes.weight) ? mdMeta.attributes.weight : 0)
|
let weight = ((mdMeta.attributes.weight) ? mdMeta.attributes.weight : 0)
|
||||||
let title = ((mdMeta.attributes.title) ? mdMeta.attributes.title : basename)
|
let title = ((mdMeta.attributes.title) ? mdMeta.attributes.title : basename)
|
||||||
let path = "/docs/" + entry.path
|
let path = "/docs/" + entry.path
|
||||||
let baseurl = endpoints.url(document, context, "/services/docs/" + path);
|
let baseurl = endpoints.url(document, context, '/services' + path);
|
||||||
console.log("baseurl for doc:" + baseurl);
|
// console.log("baseurl for doc:" + baseurl);
|
||||||
let body = endpoints.localize(mdMeta.body, baseurl)
|
let body = endpoints.localize(mdMeta.body, baseurl)
|
||||||
// console.log("path:" + entry.path)
|
// console.log("path:" + entry.path)
|
||||||
return {
|
return {
|
||||||
@ -185,7 +185,7 @@ export const actions = {
|
|||||||
categories,
|
categories,
|
||||||
weight,
|
weight,
|
||||||
title,
|
title,
|
||||||
content: mdMeta.body
|
content: body
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user