Share the page that has preview tags, not the JavaScript route
Preview crawlers do not run JavaScript, so the /v/<code> route — which is the home page plus a client-side redirect — gives them nothing. The published /v/<code>.html page carries real og:image, og:video and a real video element in the served source. Five characters longer, and the difference between a card someone taps and a bare grey link.
This commit is contained in:
parent
25ad188e99
commit
77d76f1d7f
1 changed files with 18 additions and 3 deletions
21
videos.html
21
videos.html
|
|
@ -113,9 +113,24 @@ async function load() {
|
||||||
if (!p) return;
|
if (!p) return;
|
||||||
var link = window.__shareUrl(p);
|
var link = window.__shareUrl(p);
|
||||||
if (!link) { showMsg("msg", "That one has no video yet."); return; }
|
if (!link) { showMsg("msg", "That one has no video yet."); return; }
|
||||||
// Sharing is a decision: this is what makes the link resolve at all.
|
// Publish the static page first: it is what carries the preview tags,
|
||||||
var s = await api("share_link", { email: email, project_id: p.id });
|
// and crawlers never run the JavaScript route.
|
||||||
if (!s.ok) { showMsg("msg", s.error || "Could not make a link."); return; }
|
b.disabled = true; b.textContent = "Preparing…";
|
||||||
|
var s = await api("publish_share_page", { email: email, project_id: p.id });
|
||||||
|
if (s.ok && s.pending) {
|
||||||
|
var waited = 0;
|
||||||
|
s = await new Promise(function (done) {
|
||||||
|
var t = setInterval(async function () {
|
||||||
|
waited += 4;
|
||||||
|
var g = await api("publish_share_page", { email: email, project_id: p.id });
|
||||||
|
if (g.ok && !g.pending) { clearInterval(t); done(g); return; }
|
||||||
|
if (waited > 180) { clearInterval(t); done({ ok: false, error: "That is taking unusually long." }); }
|
||||||
|
}, 4000);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
b.disabled = false; b.textContent = "Share";
|
||||||
|
if (!s.ok) { showMsg("msg", s.error || "Could not prepare that link."); return; }
|
||||||
|
if (s.note) { showMsg("msg", s.note); return; }
|
||||||
link = s.url || link;
|
link = s.url || link;
|
||||||
var title = p.title || ((p.pet_name || "Your pet") + " has something to say");
|
var title = p.title || ((p.pet_name || "Your pet") + " has something to say");
|
||||||
// The native sheet is the shortest path into a text message on a phone.
|
// The native sheet is the shortest path into a text message on a phone.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue