Skip to content

Commit 7fdadd1

Browse files
author
Gianluca Beil
committed
Vitepress build fix and search improvements
1 parent 85793f8 commit 7fdadd1

4 files changed

Lines changed: 366 additions & 29 deletions

File tree

internal/documentation/.vitepress/config.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { defineConfig } from "vitepress";
44

55
// markdown
66
import MarkdownItImplicitFigures from "markdown-it-implicit-figures";
7+
import { pagefindPlugin } from 'vitepress-plugin-pagefind'
8+
79

810
import fs from "node:fs";
911
import path from "node:path";
@@ -82,14 +84,6 @@ export default defineConfig({
8284

8385

8486
},
85-
86-
search: {
87-
provider: "local",
88-
//hotKeys: [], // disable hotkeys to avoid search while using UI5 web components input
89-
},
90-
91-
92-
9387
},
9488

9589
markdown: {
@@ -106,7 +100,8 @@ export default defineConfig({
106100
vite: {
107101
build: {
108102
chunkSizeWarningLimit: 4000, // chunk for local search index dominates
109-
}
103+
},
104+
plugins: [pagefindPlugin()]
110105
}
111106
});
112107

internal/documentation/jsdoc-to-markdown.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ for (const file of fs.readdirSync(path.join("dist", "api"))) {
150150
// Point all js links to GitHub
151151
const linkMatches = markdown.matchAll(/"[^"]*\.[A-Za-z0-9]+\.[A-Za-z0-9]+[^"]*"/g);
152152
for (const linkMatch of linkMatches) {
153+
if (!linkMatch[0].endsWith(".js.html\"")) continue;
153154
const githubUrl = packageTagName +
154-
linkMatch[0].replaceAll("\"", "").replace(".js.html", "").replaceAll("_", "/").replace("project", "") +
155+
linkMatch[0].replaceAll("\"", "").replace(".js.html", "").replaceAll("_", "/") +
155156
".js";
156157
markdown = markdown
157158
.replaceAll(linkMatch[0].replaceAll("\"", "") + "#line", githubUrl + "#L")
@@ -161,6 +162,8 @@ for (const file of fs.readdirSync(path.join("dist", "api"))) {
161162
// Add target="_blank" to the a element (Must link to external site) for a better user experience
162163
markdown = markdown.replaceAll("<a href=\"http", "<a target=\"_blank\" href=\"http");
163164

165+
markdown = stripHtmlComments(markdown);
166+
164167
for (const aElement of markdown.matchAll(aElementRegex + "g")) {
165168
deadLinksCheckPromises.push(checkDeadlinks(aElement[1], filePath));
166169
}
@@ -183,6 +186,10 @@ async function checkDeadlinks(link, sourcePath) {
183186
}
184187
}
185188

189+
function stripHtmlComments(str) {
190+
return str.replace(/<!--[\s\S]*?-->/g, "");
191+
}
192+
186193
console.log("Conversion done");
187194
console.log("Found", deadLinks.length, "dead links");
188195
if (deadLinks.length != 0) {

internal/documentation/jsdoc/templates/layout.tmpl

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,14 @@
33
// This file was initialy copied from https://github.com/clenemt/docdash/blob/-/tmpl/layout.tmpl
44
// and adjusted to offer a customized footer according to the SAP Web Presence Policy.
55
// See also the corresponding stylesheet content in lib/jsdoc/plugin/template/custom.css.
6-
// ##### END: MODIFIED BY SAP
76
?>
87

9-
<div id="main">
108
<?js if (title != 'Home') { ?>
119
<h1 class="page-title"><?js= title ?></h1>
1210
<?js } ?>
1311

1412
<?js= content ?>
15-
16-
<?js if (env.conf.docdash.disqus) { ?>
17-
<div id="disqus_thread"></div>
18-
<script>
19-
(function() { // DON'T EDIT BELOW THIS LINE
20-
var d = document, s = d.createElement('script');
21-
s.src = '//<?js= env.conf.docdash.disqus ?>.disqus.com/embed.js';
22-
s.setAttribute('data-timestamp', +new Date());
23-
(d.head || d.body).appendChild(s);
24-
})();
25-
</script>
26-
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
27-
<?js } ?>
28-
</div>
29-
</html>
13+
14+
<?js
15+
// ##### END: MODIFIED BY SAP
16+
?>

0 commit comments

Comments
 (0)