openvibers/openvibe.live Commits

Docs pages share with the site's card (og:image, twitter:card), and the API docs install openvibe-sdk v0.54.0 (#275)

OP OpenVibers committed 24 days ago · 74f9eff7c2 · 3 files, +8 −2

Changes

ddiff --git a/public/fragments/documentation.html b/public/fragments/documentation.html
iindex 43db8b34..d9522527 100644
---- a/public/fragments/documentation.html
++++ b/public/fragments/documentation.html
@@@ -288,7 +288,7 @@ const { stream, endpoint } = await fetch('https://openvibe.live/api/streams', {
console.log(endpoint.whipUrlBase); // POST your SDP offer here (see WebRTC tab)
</code></pre>
<h3>The same with openvibe-sdk</h3>
--<p>In Node, <code>npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.52.0</code> and use <code>openvibe-sdk/live</code>: who is live, channels, slots, going live, the session, the content feeds and WHIP, with errors as <code>OpenVibeError</code> (<a href="https://github.com/OpenVibers/OpenVibe.SDK#readme" target="_blank" rel="noopener">SDK README</a>).</p>
++<p>In Node, <code>npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.54.0</code> and use <code>openvibe-sdk/live</code>: who is live, channels, slots, going live, the session, the content feeds and WHIP, with errors as <code>OpenVibeError</code> (<a href="https://github.com/OpenVibers/OpenVibe.SDK#readme" target="_blank" rel="noopener">SDK README</a>).</p>
<pre><code>const { createClient } = require('openvibe-sdk');
const { createLiveClient } = require('openvibe-sdk/live');
const live = createLiveClient(createClient({ token: TOKEN })); // openvibe.live is found through the network registry
ddiff --git a/server/docs/routes.js b/server/docs/routes.js
iindex 03059a8a..cee1250e 100644
---- a/server/docs/routes.js
++++ b/server/docs/routes.js
@@@ -16,6 +16,7 @@ const express = require('express');
const fs = require('fs');
const path = require('path');
const cache = require('openvibe-shared/cache-policy');
++const social = require('openvibe-shared/social');
const router = express.Router();
// Through OV_APP_ROOT (the `current` release symlink) when set, so doc edits go live without a restart.
@@@ -256,7 +257,9 @@ function renderPage({ name, title, html, headings }) {
<meta property="og:site_name" content="OpenVibe.Live">
<meta property="og:title" content="${escapeHtml(title || 'OpenVibe.Live Docs')}">
<meta property="og:description" content="${escapeHtml(description)}">
-- <meta property="og:url" content="${escapeHtml(canonical)}">` : ''}
++ <meta property="og:url" content="${escapeHtml(canonical)}">
++ <meta property="og:image" content="${escapeHtml(new URL(social.url('live') || '/og-image.png', canonical).href)}">
++ <meta name="twitter:card" content="summary_large_image">` : ''}
<style>
:root { --bg: #0d0d0f; --bg-2: #16161a; --bg-3: #1e1e24; --text: #e8e6e3; --text-2: #9a9a9a; --muted: #666;
--accent: #8b5cf6; --accent-light: #a78bfa; --border: #2a2a32; }
ddiff --git a/test/docs-render.test.js b/test/docs-render.test.js
iindex 62dbc0ca..652c7e26 100644
---- a/test/docs-render.test.js
++++ b/test/docs-render.test.js
@@@ -94,6 +94,9 @@ assert.ok(renderPage({ name: 'README', title: '', html: '', headings: [] }).incl
const described = renderPage({ name: 'go-live-in-your-browser', title: 'Go live', html: '<h1>Go live</h1>\n<p>Start in your <strong>browser</strong> &amp; go.</p><p>later</p>', headings: [] });
assert.ok(described.includes('<meta name="description" content="Start in your browser &amp; go.">'), described.slice(0, 900));
assert.ok(described.includes('<meta property="og:url" content="https://openvibe.live/docs/go-live-in-your-browser">'));
++// A shared docs link has the site's card (openvibe-shared/social), not a bare preview.
++assert.match(described, /<meta property="og:image" content="https:\/\/openvibe\.live\/shared\/social\/live\.jpg\?v=[0-9a-f]+">/);
++assert.ok(described.includes('<meta name="twitter:card" content="summary_large_image">'));
assert.ok(!renderPage({ name: 'x', title: 'X', html: '<h2>no paragraph</h2>', headings: [] }).includes('name="description"'), 'no paragraph, no description');
assert.ok(shell.includes('<link rel="icon" type="image/svg+xml" href="/assets/logo.svg">'));
assert.ok(fs.existsSync(path.join(__dirname, '..', 'public', 'assets', 'logo.svg')), 'the icon file exists');