openvibers/openvibe.surf Commits

Add WebSite + Organization JSON-LD to the home page (#44)

OP OpenVibers committed 12 days ago · 68aa1c6c58 · 2 files, +6 −1

Changes

ddiff --git a/server/views/index.js b/server/views/index.js
iindex c894eec..bd1352f 100644
---- a/server/views/index.js
++++ b/server/views/index.js
@@@ -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) {
ddiff --git a/test/pages.test.js b/test/pages.test.js
iindex 4ed3001..59d3eeb 100644
---- a/test/pages.test.js
++++ b/test/pages.test.js
@@@ -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);
});