You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by zr...@apache.org on 2020/11/03 13:34:09 UTC
[camel-website] branch master updated (5f78137 -> c2b5b1e)
This is an automated email from the ASF dual-hosted git repository.
zregvart pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel-website.git.
from 5f78137 refactor: speedup relative links rule
new 3e8d717 fix: extra comma in the JSON-LD data
new c2b5b1e chore: add rule to check JSON-LD structured data
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.htmlvalidate.json | 3 +-
.../src/partials/breadcrumbs-microdata.hbs | 13 +++----
rules.js | 40 +++++++++++++++++++++-
3 files changed, 48 insertions(+), 8 deletions(-)
[camel-website] 02/02: chore: add rule to check JSON-LD structured
data
Posted by zr...@apache.org.
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
commit c2b5b1e287f433b2e261e65ced7073c6ebd3fc77
Author: Zoran Regvart <zr...@apache.org>
AuthorDate: Tue Nov 3 13:49:19 2020 +0100
chore: add rule to check JSON-LD structured data
---
.htmlvalidate.json | 3 ++-
rules.js | 40 +++++++++++++++++++++++++++++++++++++++-
2 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/.htmlvalidate.json b/.htmlvalidate.json
index 1c69ddf..64899fb 100644
--- a/.htmlvalidate.json
+++ b/.htmlvalidate.json
@@ -12,6 +12,7 @@
"element-required-attributes": "off",
"prefer-tbody": "off",
"long-title": "off",
- "camel/title": "error"
+ "camel/title": "error",
+ "camel/structured-data": "error"
}
}
diff --git a/rules.js b/rules.js
index 9271c3f..2bf21ec 100644
--- a/rules.js
+++ b/rules.js
@@ -49,9 +49,47 @@ class RelativeLinks extends Rule {
}
}
+class StructuredData extends Rule {
+ documentation(context) {
+ return {
+ description: "Validates JSON-LD according to schema.org"
+ };
+ }
+
+ setup() {
+ let start = -1;
+
+ this.on('tag:open', event => {
+ if (event.target.nodeName === 'script') {
+ start = event.target.location.offset;
+ }
+ });
+
+ this.on('tag:close', async event => {
+ const tag = event.previous;
+ if (event.target.nodeName === 'script' && tag.hasAttribute('type') && tag.getAttribute('type').value === 'application/ld+json') {
+ const startIdx = data.indexOf('>', start) + 1;
+ const endIdx = event.target.location.offset - 1; // omit the opening tag angled bracket
+ const content = data.substring(startIdx, endIdx);
+ try {
+ JSON.parse(content);
+ } catch (err) {
+ this.report(tag, `Unable to parse JSON-LD as JSON: ${err}`);
+ }
+ }
+ });
+ }
+}
+
+let data;
+
module.exports = {
+ setup(source) {
+ data = source.data;
+ },
rules: {
"camel/title": HtmlTitle,
- "camel/relative-links": RelativeLinks
+ "camel/relative-links": RelativeLinks,
+ "camel/structured-data": StructuredData
}
};
[camel-website] 01/02: fix: extra comma in the JSON-LD data
Posted by zr...@apache.org.
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
commit 3e8d717038d2fa0f6d1dc37dd20cc4cdbb9a798a
Author: Zoran Regvart <zr...@apache.org>
AuthorDate: Tue Nov 3 10:12:45 2020 +0100
fix: extra comma in the JSON-LD data
We have an issue in the generated JSON-LD data, there is an extra comma
being generated, and the URLs are not absolute (as the site.url no
longer is).
---
antora-ui-camel/src/partials/breadcrumbs-microdata.hbs | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/antora-ui-camel/src/partials/breadcrumbs-microdata.hbs b/antora-ui-camel/src/partials/breadcrumbs-microdata.hbs
index 613bd1a..2c5badb 100644
--- a/antora-ui-camel/src/partials/breadcrumbs-microdata.hbs
+++ b/antora-ui-camel/src/partials/breadcrumbs-microdata.hbs
@@ -6,30 +6,31 @@
"@type": "ListItem",
"position": 1,
"name": "{{{site.title}}}",
- "item": "{{{site.url}}}"
+ "item": "https://camel.apache.org/"
},
{
"@type": "ListItem",
"position": 2,
"name": "{{{page.component.title}}}",
- "item": "{{{add site.url page.component.url}}}"
+ "item": "https://camel.apache.org{{{page.component.url}}}"
},
{
"@type": "ListItem",
"position": 3,
"name": "{{{page.componentVersion.displayVersion}}}",
- "item": "{{{add site.url page.componentVersion.url}}}"
+ "item": "https://camel.apache.org{{{page.componentVersion.url}}}"
}
{{#if page.breadcrumbs}}
+ ,
{{#each page.breadcrumbs}}
- ,{
+ {
"@type": "ListItem",
"position": {{add @index 4}},
"name": "{{{ ./content }}}",
{{~#if (and ./url (eq ./urlType 'internal'))~}}
- "item": "{{{add ../site.url ./url}}}"
+ "item": "https://camel.apache.org{{{./url}}}"
{{~else~}}
- "item": "{{{add ../site.url ../page.componentVersion.url}}}"
+ "item": "https://camel.apache.org{{{../page.componentVersion.url}}}"
{{~/if~}}
}
{{#unless @last}}