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 {
|
||||
/**
|
||||
* 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) {
|
||||
console.log("isDev=" + context.isDev)
|
||||
console.log("document.location=" + JSON.stringify(document.location, null, 2))
|
||||
// console.log("isDev=" + context.isDev)
|
||||
// console.log("document.location=" + JSON.stringify(document.location, null, 2))
|
||||
|
||||
let origin = document.location.origin;
|
||||
let base = origin;
|
||||
base = origin.replace(":3003", ":12345")
|
||||
|
||||
if (origin.includes(":3003")) {
|
||||
base = origin.replace(":3003", ":12345")
|
||||
}
|
||||
console.log("base=" + base);
|
||||
// console.log("base=" + base + ", path=" + path);
|
||||
let url = base + path;
|
||||
console.log("url=" + url);
|
||||
// console.log("url=" + url);
|
||||
return url;
|
||||
},
|
||||
localize(body, baseurl) {
|
||||
// console.log("localize([body],baseurl='" + baseurl + "'")
|
||||
// const regex = /\[([^/][^]]+)]/;
|
||||
// let remaining = body;
|
||||
//
|
||||
// while (remaining.)
|
||||
//
|
||||
return body;
|
||||
localize(body, docurl) {
|
||||
let localized = body;
|
||||
// console.log("localizing " + details.path)
|
||||
let offset = docurl.lastIndexOf("/")
|
||||
let baseurl = docurl.slice(0, offset + 1)
|
||||
|
||||
let replacer = function (match, p1, p2, p3, groups) {
|
||||
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 title = ((mdMeta.attributes.title) ? mdMeta.attributes.title : basename)
|
||||
let path = "/docs/" + entry.path
|
||||
let baseurl = endpoints.url(document, context, "/services/docs/" + path);
|
||||
console.log("baseurl for doc:" + baseurl);
|
||||
let baseurl = endpoints.url(document, context, '/services' + path);
|
||||
// console.log("baseurl for doc:" + baseurl);
|
||||
let body = endpoints.localize(mdMeta.body, baseurl)
|
||||
// console.log("path:" + entry.path)
|
||||
return {
|
||||
@ -185,7 +185,7 @@ export const actions = {
|
||||
categories,
|
||||
weight,
|
||||
title,
|
||||
content: mdMeta.body
|
||||
content: body
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user