Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Commit eb88b01

Browse files
author
Alexander Biehl
committed
QuickNav: Make docbase configurable
1 parent 24ccb9b commit eb88b01

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

haddock-api/resources/html/index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
quickNav = (function() {
2+
3+
var baseUrl;
4+
15
// alias preact's hyperscript reviver since it's referenced a lot:
26
var h = preact.h;
37

@@ -256,7 +260,7 @@ var App = createClass({
256260

257261
var renderItem = function(item) {
258262
return h('li', { class: 'search-result' },
259-
this.navigationLink(item.link, {},
263+
this.navigationLink(baseUrl + "/" + item.link, {},
260264
h(DocHtml, { html: item.display_html })
261265
)
262266
);
@@ -379,4 +383,10 @@ var NoResultsMsg = function(props) {
379383
return messages[(props.searchString || 'a').charCodeAt(0) % messages.length];
380384
};
381385

382-
preact.render(h(App), document.body);
386+
return {
387+
init: function(docBaseUrl) {
388+
baseUrl = docBaseUrl || "";
389+
preact.render(h(App), document.body);
390+
}
391+
}
392+
})();

haddock-api/src/Haddock/Backends/Xhtml.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,12 @@ bodyHtml doctitle iface
194194

195195
script ! [src jsPreactFile, thetype "text/javascript"] << noHtml,
196196
script ! [src jsFuseFile, thetype "text/javascript"] << noHtml,
197-
script ! [src jsIndexFile, thetype "text/javascript"] << noHtml
197+
script ! [src jsIndexFile, thetype "text/javascript"] << noHtml,
198+
script ! [thetype "text/javascript"]
199+
-- NB: Within XHTML, the content of script tags needs to be
200+
-- a <![CDATA[ section.
201+
<< primHtml
202+
"//<![CDATA[\nquickNav.init();\n//]]>\n"
198203
]
199204

200205
moduleInfo :: Interface -> Html

0 commit comments

Comments
 (0)