This is an automated email from the ASF dual-hosted git repository.
zregvart pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-website.git
The following commit(s) were added to refs/heads/master by this push:
new 426b3eb chore: add rule to check for absolute links
426b3eb is described below
commit 426b3ebb3cf2a2e053435ecd4b2b81ada192b2a4
Author: Zoran Regvart <[email protected]>
AuthorDate: Mon Nov 2 15:15:32 2020 +0100
chore: add rule to check for absolute links
---
.htmlvalidate.json | 4 ++--
rules.js | 22 +++++++++++++++++++++-
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/.htmlvalidate.json b/.htmlvalidate.json
index 7d21cd6..41a00da 100644
--- a/.htmlvalidate.json
+++ b/.htmlvalidate.json
@@ -12,7 +12,7 @@
"element-required-attributes": "off",
"prefer-tbody": "off",
"long-title": "off",
- "camel/title": "error"
+ "camel/title": "error",
+ "camel/relative-links": "error"
}
}
-
diff --git a/rules.js b/rules.js
index 3dce28d..a76c7d6 100644
--- a/rules.js
+++ b/rules.js
@@ -26,8 +26,28 @@ class HtmlTitle extends Rule {
}
}
+class RelativeLinks extends Rule {
+ documentation(context) {
+ return {
+ description: "Within the Camel site we should use only relative links"
+ };
+ }
+
+ setup() {
+ this.on("dom:ready", event => {
+ event.document.querySelectorAll('a').forEach(a => {
+ const href = a.getAttribute("href").value;
+ if (href && href.startsWith("https://camel.apache.org")) {
+ this.report(a, `For links within camel.apache.org use relative
links, found: ${href}`);
+ }
+ });
+ });
+ }
+}
+
module.exports = {
rules: {
- "camel/title": HtmlTitle
+ "camel/title": HtmlTitle,
+ "camel/relative-links": RelativeLinks
}
};