You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2021/03/10 15:58:33 UTC
[skywalking-website] branch master updated: Resolve image links
(#242)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-website.git
The following commit(s) were added to refs/heads/master by this push:
new 0313319 Resolve image links (#242)
0313319 is described below
commit 03133193d653928e36b9c52f1ef8fa20e2c60941
Author: Juntao Zhang <jt...@163.com>
AuthorDate: Wed Mar 10 23:58:23 2021 +0800
Resolve image links (#242)
---
docs.js | 46 +++++++--------
themes/docsy/layouts/shortcodes/blocks/events.html | 66 ----------------------
2 files changed, 23 insertions(+), 89 deletions(-)
diff --git a/docs.js b/docs.js
index d5a1488..47c22fe 100644
--- a/docs.js
+++ b/docs.js
@@ -13,8 +13,8 @@ init();
async function init() {
try {
const targetPath = path.join(__dirname, layoutTemplateFile)
- const result = await loadYaml(docConfig)
- const {tpl, docsInfo} = await traverseDocsList(result)
+ const docsList = await loadYaml(docConfig)
+ const {tpl, docsInfo} = await traverseDocsList(docsList)
await generateLayoutTemplate(targetPath, tpl)
handleDocsFiles(docsInfo)
} catch (err) {
@@ -29,6 +29,10 @@ function readDirSync(path, docInfo, replaceMarkdownText) {
pa.forEach(function (ele) {
const filePath = path + "/" + ele
const info = fs.statSync(filePath);
+ if (info.isDirectory()) {
+ readDirSync(filePath, docInfo, replaceMarkdownText);
+ return;
+ }
if (isImage(ele)) {
const {docName, version} = docInfo;
const imgName = `${docName}_${version}_${ele}`;
@@ -37,15 +41,12 @@ function readDirSync(path, docInfo, replaceMarkdownText) {
throw err
}
});
+ return;
}
- if (info.isDirectory()) {
- readDirSync(filePath, docInfo, replaceMarkdownText);
- } else {
- const fileNameReg = /\.md/g;
- let shouldFormat = fileNameReg.test(filePath);
- if (shouldFormat) {
- readFile(filePath, docInfo, replaceMarkdownText);
- }
+ const reg = /\.md/gi;
+ const shouldFormat = reg.test(filePath);
+ if (shouldFormat) {
+ readFile(filePath, docInfo, replaceMarkdownText);
}
});
}
@@ -62,10 +63,9 @@ function readFile(filePath, docInfo, replaceMarkdownText) {
});
}
-function isImage(filePath) {
- var index = filePath.lastIndexOf(".");
- var ext = filePath.substr(index + 1);
- return ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'webp', 'svg', 'tiff'].indexOf(ext.toLowerCase()) > -1;
+function isImage(file) {
+ var reg = /(.*)\.(jpg|jpeg|png|bmp|gif|ico|pcx|tif|tiff|raw|tga|webp|svg)$/;
+ return reg.test(file)
}
function replaceMarkdownText(codeTxt, docInfo, filePath) {
@@ -87,7 +87,7 @@ layout: baseof
---\n` + codeTxt;
codeTxt = codeTxt
.replace(/(\[[\s\S]*?\])\(([\s\S]*?)\)/g, function (match, p1, p2) {
- if (p2 && p2.startsWith('http')) {
+ if (p2 && p2.startsWith('http') || isImage(p2)) {
return match
}
if (p2.startsWith('../')) {
@@ -105,7 +105,7 @@ layout: baseof
return `${p1}(${str})`
}
if (str.startsWith('./')) {
- return `${p1}(./../${str})`
+ return `${p1}(./../${str.slice(2)})`
}
return `${p1}(../${str})`
})
@@ -116,13 +116,13 @@ layout: baseof
const imgName = `${docName}_${version}_` + p2.split('/').pop();
return `<img${p1}src="/images/${imgName}"${p3}>`
})
- /*.replace(/(\!\[[\s\S]*?\])\((.*?)\)/g, function (match, p1, p2,) {
- if (p2 && p2.startsWith('http')) {
- return match
- }
- const imgName = `${docName}_${version}_` + p2.split('/').pop();
- return `${p1}(/images/${imgName})`
- })*/
+ .replace(/(\!\[[\s\S]*?\])\((.*?)\)/g, function (match, p1, p2,) {
+ if (p2 && p2.startsWith('http')) {
+ return match
+ }
+ const imgName = `${docName}_${version}_` + p2.split('/').pop();
+ return `${p1}(/images/${imgName})`
+ })
}
return codeTxt
}
diff --git a/themes/docsy/layouts/shortcodes/blocks/events.html b/themes/docsy/layouts/shortcodes/blocks/events.html
index c55dfc5..4e147bb 100644
--- a/themes/docsy/layouts/shortcodes/blocks/events.html
+++ b/themes/docsy/layouts/shortcodes/blocks/events.html
@@ -1,77 +1,11 @@
{{ .Inner | markdownify}}
-<!--
-<div class="events-wrapper flex-wrapper">
- {{ range first 4 (where .Site.Pages "Section" "events") }}
- <div class="">
- <h5 class="mt-0 mb-1"><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h5>
- <span class="date">{{ .Date.Format "Mon, Jan 2, 2006" }}</span>
- <p class="pt-0 mt-0">{{ .Plain | safeHTML | truncate 150 }}</p>
- <!– <p class="pt-0 mt-0">{{ .Description }}</p>–>
- <p class="pt-0"><a href="{{ .RelPermalink }}">{{ T "ui_read_more"}}</a></p>
- </div>
-
- {{ end }}
-</div>
--->
-
-<style>
- .fr{
- float: right;
- }
-</style>
-
-
{{ range first 4 (where .Site.Pages "Section" "events") }}
-<!--
- <h5 class="mt-0 mb-1"><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h5>
- <span class="date">{{ .Date.Format "Mon, Jan 2, 2006" }}</span>
- <p class="pt-0 mt-0">{{ .Plain | safeHTML | truncate 150 }}</p>
- <!– <p class="pt-0 mt-0">{{ .Description }}</p>–>
- <p class="pt-0"><a href="{{ .RelPermalink }}">{{ T "ui_read_more"}}</a></p>
-
-
--->
<div class="home-event-li">
<h5 class="mt-0 mb-1"><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h5>
<span class="time">{{ .Date.Format "Mon, Jan 2, 2006" }}</span>
<p>{{ .Plain | safeHTML | truncate 100 }}</p>
-<!-- <span class="pt-0 fr"><a href="{{ .RelPermalink }}">{{ T "ui_read_more"}}</a></span>-->
</div>
{{ end }}
-
-
-
-<!-- TODO
-<div id="overview" class="bg-box event">
- <div class="contain">
- <h2 class="section-head">Events & News</h2>
-
- <div class="container flex-wrapper">
-
- <div class="home-event-li">
- <h5>SkyWalking Cloud on Kubernetes 0.1.0 is released</h5>
- <p class="time"> Nov. 16th, 2020</p>
- <p>OAPServer CRDs and controller.</p>
- </div>
- <div class="home-event-li">
- <h5>Welcome Jiapeng Liu as new committer</h5>
- <p class="time"> Nov. 5th, 2020</p>
- <p>Based on his continuous contributions, Jiapeng Liu (a.k.a <a href="https://github.com/evanljp">evanljp</a> has been voted as a new committer.</p>
- </div>
- <div class="home-event-li">
- <h5>SkyWalking Kubernetes Helm Chart 4.0.0 is released</h5>
- <p class="time"> Nov. 3rd, 2020</p>
- <p>Allow overriding default configurations files; Unify usages of different SkyWalking Versions.</p>
- </div>
- <div class="home-event-li">
- <h5>SkyWalking Client JS 0.1.0 is released</h5>
- <p class="time"> Oct. 30th, 2020</p>
- <p>Support Browser Side Monitoring. Require SkyWalking APM 8.2+.</p>
- </div>
- </div>
- </div>
-</div>
--->