openvibers/openvibe.surf Commits
Add WebSite + Organization JSON-LD to the home page (#44)
Changes
@@@ -14,6 +14,7 @@*/const layoutLib = require('../render/layout');const kit = require('openvibe-shared/kit');++const seo = require('openvibe-shared/seo');const S = require('./short');const sc = require('openvibe-shared/showcase');const rooms = require('openvibe-shared/rooms');@@@ -91,7 +92,7 @@ function home() {body = S.foldSection(body, 'id="sc-questions"', 'questions-fold');// The rule that shows the picked scene: one per scene, so the CSS is written for this page.const rules = `@supports selector(:has(*)){@media (max-width:640px){${S.pickRules('scenes', ['scene-0', 'scene-1', 'scene-2'])}}}`;-- return layout({ title: null, path: '/', body: `<div class="sf-wrap">${body}</div>`, active: '/', inlineStyles: [rules] });++ return layout({ title: null, path: '/', body: `<div class="sf-wrap">${body}</div>`, active: '/', jsonLd: [seo.jsonLd.website({ name: 'OpenVibe.Surf', url: 'https://openvibe.surf/', description: 'Ride CS-style surf maps in the browser, surf what is live on OpenVibe.Live, and let an agent browse the web for you.' }), seo.jsonLd.organization()], inlineStyles: [rules] });}function mapCard(m) {@@@ -21,6 +21,10 @@ const { assetVersion } = require('../server/assets');assert.match(r.text, /href="\/watch"/);assert.match(r.text, /href="\/web"/);assert.match(r.text, /<main id="main"/);++ const ld = [...r.text.matchAll(/<script type="application\/ld\+json">([\s\S]*?)<\/script>/g)].map((m) => JSON.parse(m[1])).flatMap((b) => b['@graph'] || [b]);++ assert.ok(ld.some((x) => x['@type'] === 'WebSite'), 'home has WebSite JSON-LD');++ const org = ld.find((x) => x['@type'] === 'Organization');++ assert.ok(org && Array.isArray(org.sameAs) && org.sameAs.includes('https://github.com/OpenVibers'), 'home has the OpenVibe Organization');assert.strictEqual(r.headers.get('cache-control'), 'public, max-age=60');assert.match(r.headers.get('vary'), /Cookie/i);});
@@ -14,6 +14,7 @@
@@ -14,6 +14,7 @@
*/
*/
const layoutLib = require('../render/layout');
const layoutLib = require('../render/layout');
const kit = require('openvibe-shared/kit');
const kit = require('openvibe-shared/kit');
+const seo = require('openvibe-shared/seo');
const S = require('./short');
const S = require('./short');
const sc = require('openvibe-shared/showcase');
const sc = require('openvibe-shared/showcase');
const rooms = require('openvibe-shared/rooms');
const rooms = require('openvibe-shared/rooms');
@@ -91,7 +92,7 @@ function home() {
@@ -91,7 +92,7 @@ function home() {
body = S.foldSection(body, 'id="sc-questions"', 'questions-fold');
body = S.foldSection(body, 'id="sc-questions"', 'questions-fold');
// The rule that shows the picked scene: one per scene, so the CSS is written for this page.
// The rule that shows the picked scene: one per scene, so the CSS is written for this page.
const rules = `@supports selector(:has(*)){@media (max-width:640px){${S.pickRules('scenes', ['scene-0', 'scene-1', 'scene-2'])}}}`;
const rules = `@supports selector(:has(*)){@media (max-width:640px){${S.pickRules('scenes', ['scene-0', 'scene-1', 'scene-2'])}}}`;
- return layout({ title: null, path: '/', body: `<div class="sf-wrap">${body}</div>`, active: '/', inlineStyles: [rules] });
+ return layout({ title: null, path: '/', body: `<div class="sf-wrap">${body}</div>`, active: '/', jsonLd: [seo.jsonLd.website({ name: 'OpenVibe.Surf', url: 'https://openvibe.surf/', description: 'Ride CS-style surf maps in the browser, surf what is live on OpenVibe.Live, and let an agent browse the web for you.' }), seo.jsonLd.organization()], inlineStyles: [rules] });
}
}
function mapCard(m) {
function mapCard(m) {
@@ -21,6 +21,10 @@ const { assetVersion } = require('../server/assets');
@@ -21,6 +21,10 @@ const { assetVersion } = require('../server/assets');
assert.match(r.text, /href="\/watch"/);
assert.match(r.text, /href="\/watch"/);
assert.match(r.text, /href="\/web"/);
assert.match(r.text, /href="\/web"/);
assert.match(r.text, /<main id="main"/);
assert.match(r.text, /<main id="main"/);
+ const ld = [...r.text.matchAll(/<script type="application\/ld\+json">([\s\S]*?)<\/script>/g)].map((m) => JSON.parse(m[1])).flatMap((b) => b['@graph'] || [b]);
+ assert.ok(ld.some((x) => x['@type'] === 'WebSite'), 'home has WebSite JSON-LD');
+ const org = ld.find((x) => x['@type'] === 'Organization');
+ assert.ok(org && Array.isArray(org.sameAs) && org.sameAs.includes('https://github.com/OpenVibers'), 'home has the OpenVibe Organization');
assert.strictEqual(r.headers.get('cache-control'), 'public, max-age=60');
assert.strictEqual(r.headers.get('cache-control'), 'public, max-age=60');
assert.match(r.headers.get('vary'), /Cookie/i);
assert.match(r.headers.get('vary'), /Cookie/i);
});
});