openvibers/openvibe.tips Commits

Home says what the site is in structured data (WebSite + WebPage JSON-LD, as the other OpenVibe homes do) (#70)

OP OpenVibers committed 27 days ago · 5894b16928 · 2 files, +8 −1

Changes

ddiff --git a/server/web/routes.js b/server/web/routes.js
iindex 1a68dce..983c344 100644
---- a/server/web/routes.js
++++ b/server/web/routes.js
@@@ -27,6 +27,7 @@ const cache = require('openvibe-shared/cache-policy');
const frame = require('openvibe-shared/frame');
const legal = require('openvibe-shared/legal');
const seo = require('openvibe-shared/seo');
++const HOME_DESCRIPTION = 'Support the creators you watch on OpenVibe: tips, goals, paid messages, text-to-speech and media requests, with stream overlays for creators.';
const express = require('express');
const { sql } = require('openvibe-sdk/db');
const { TipsError } = require('../util');
@@@ -81,7 +82,12 @@ function createWebRoutes({ domain, config, layout, userAuth }) {
// ── Home, robots, sitemap ────────────────────────────────
r.get('/', withViewer, async (req, res) => {
const creators = await db.many(sql`SELECT handle, display_name, avatar_url FROM creator_tip_profiles WHERE page_enabled ORDER BY updated_at DESC LIMIT 24`);
-- html(res, pageFor(req, { active: 'home', canonicalPath: '/', styles: [require('openvibe-shared/showcase').STYLESHEET], body: pages.home({ creators }) }));
++ // What the site is, for search engines (WebSite + WebPage, as the other OpenVibe homes say it).
++ const jsonLd = [
++ seo.jsonLd.website({ name: 'OpenVibe.Tips', url: config.baseUrl, description: HOME_DESCRIPTION }),
++ seo.jsonLd.webPage({ name: 'OpenVibe.Tips', url: `${config.baseUrl}/`, description: HOME_DESCRIPTION, siteUrl: config.baseUrl }),
++ ];
++ html(res, pageFor(req, { active: 'home', canonicalPath: '/', styles: [require('openvibe-shared/showcase').STYLESHEET], body: pages.home({ creators }), jsonLd }));
});
// What shipped on OpenVibe.Tips: the shared update log every OpenVibe site has.
r.get('/updates', withViewer, (req, res) => html(res, pageFor(req, { canonicalPath: '/updates', title: 'What shipped on OpenVibe.Tips', body: frame.updatesBody({ service: 'tips', siteName: 'OpenVibe.Tips' }) + `<script src="${ovServe.url('shipped.js')}" defer></script>` })));
ddiff --git a/test/pages.test.js b/test/pages.test.js
iindex a5a0b41..052b104 100644
---- a/test/pages.test.js
++++ b/test/pages.test.js
@@@ -29,6 +29,7 @@ const { boot, check, done } = require('./helpers/app');
assert.match(r.text, /\/shared\/navbar\.js\?v=[0-9a-f]{12}/);
assert.match(r.text, /<meta name="ov-release"/);
assert.match(r.text, /id="ov-footer"|class="ovf/);
++ assert.match(r.text, /<script type="application\/ld\+json">[^<]*"@type":"WebSite"[^<]*"name":"OpenVibe.Tips"/, 'the home says what the site is (JSON-LD)');
assert.match(r.text, /href="\/alex"/);
assert.ok(!r.text.includes('href="/bob"'), 'switched-off pages are not listed');
// The home opens with the showcase kit (openvibe-shared/showcase): one h1 (the hero), the kit's sheet, the