openvibers/openvibe.rent Commits
OpenVibe.Homes: the home says what the site is in structured data (WebSite + WebPage JSON-LD) (#76)
Changes
@@@ -19,6 +19,8 @@const express = require('express');const cache = require('openvibe-shared/cache-policy');const showcase = require('openvibe-shared/showcase');++const seo = require('openvibe-shared/seo');++const HOMES_SUMMARY = 'Buying a home: one search across Zillow, Realtor.com, Redfin, Homes.com, Trulia and Craigslist, with HUD and Fannie Mae homes, foreclosure auctions and county property records.';const { send } = require('../render/layout');const { html, raw, notice } = require('../render/html');const sites = require('./sites');@@@ -53,6 +55,11 @@ function createHomesRoutes(ctx) {// ── Home ─────────────────────────────────────────────────r.get('/', (req, res) => page(req, res, {index: true, cache: PUBLIC_CACHE,++ // What the site is, for search engines (WebSite + WebPage, as the other OpenVibe homes say it).++ jsonLd: [++ seo.jsonLd.website({ name: 'OpenVibe.Homes', url: base, description: HOMES_SUMMARY }),++ seo.jsonLd.webPage({ name: 'OpenVibe.Homes', url: `${base}/`, description: HOMES_SUMMARY, siteUrl: base }),++ ],description: 'Buying a home: one search opens Zillow, Realtor.com, Redfin, Homes.com, Trulia and Craigslist, with HUD and Fannie Mae homes, foreclosure auctions, county property records and a mortgage calculator.',styles: [showcase.STYLESHEET], localStyles: ['css/everywhere.css', 'css/homes.css'],body: html`${raw(showcase.hero({@@@ -74,6 +74,7 @@ const housingFetchImpl = async (url) => (new URL(String(url)).pathname.endsWith(const r = await homes('/');assert.strictEqual(r.status, 200);assert.ok(r.text.includes('Buying a home?') && r.text.includes('OpenVibe.Homes'));++ assert.ok(/<script type="application\/ld\+json">[^<]*"@type":"WebSite"[^<]*"name":"OpenVibe.Homes"/.test(r.text), 'the home says what the site is (JSON-LD)');assert.ok(r.text.includes('<link rel="canonical" href="https://openvibe.homes/">'), 'its own canonical');const rent = await t.get('/');assert.ok(!rent.text.includes('Buying a home?'), 'Rent still serves Rent');
@@ -19,6 +19,8 @@
@@ -19,6 +19,8 @@
const express = require('express');
const express = require('express');
const cache = require('openvibe-shared/cache-policy');
const cache = require('openvibe-shared/cache-policy');
const showcase = require('openvibe-shared/showcase');
const showcase = require('openvibe-shared/showcase');
+const seo = require('openvibe-shared/seo');
+const HOMES_SUMMARY = 'Buying a home: one search across Zillow, Realtor.com, Redfin, Homes.com, Trulia and Craigslist, with HUD and Fannie Mae homes, foreclosure auctions and county property records.';
const { send } = require('../render/layout');
const { send } = require('../render/layout');
const { html, raw, notice } = require('../render/html');
const { html, raw, notice } = require('../render/html');
const sites = require('./sites');
const sites = require('./sites');
@@ -53,6 +55,11 @@ function createHomesRoutes(ctx) {
@@ -53,6 +55,11 @@ function createHomesRoutes(ctx) {
// ── Home ─────────────────────────────────────────────────
// ── Home ─────────────────────────────────────────────────
r.get('/', (req, res) => page(req, res, {
r.get('/', (req, res) => page(req, res, {
index: true, cache: PUBLIC_CACHE,
index: true, cache: PUBLIC_CACHE,
+ // What the site is, for search engines (WebSite + WebPage, as the other OpenVibe homes say it).
+ jsonLd: [
+ seo.jsonLd.website({ name: 'OpenVibe.Homes', url: base, description: HOMES_SUMMARY }),
+ seo.jsonLd.webPage({ name: 'OpenVibe.Homes', url: `${base}/`, description: HOMES_SUMMARY, siteUrl: base }),
+ ],
description: 'Buying a home: one search opens Zillow, Realtor.com, Redfin, Homes.com, Trulia and Craigslist, with HUD and Fannie Mae homes, foreclosure auctions, county property records and a mortgage calculator.',
description: 'Buying a home: one search opens Zillow, Realtor.com, Redfin, Homes.com, Trulia and Craigslist, with HUD and Fannie Mae homes, foreclosure auctions, county property records and a mortgage calculator.',
styles: [showcase.STYLESHEET], localStyles: ['css/everywhere.css', 'css/homes.css'],
styles: [showcase.STYLESHEET], localStyles: ['css/everywhere.css', 'css/homes.css'],
body: html`${raw(showcase.hero({
body: html`${raw(showcase.hero({
@@ -74,6 +74,7 @@ const housingFetchImpl = async (url) => (new URL(String(url)).pathname.endsWith(
@@ -74,6 +74,7 @@ const housingFetchImpl = async (url) => (new URL(String(url)).pathname.endsWith(
const r = await homes('/');
const r = await homes('/');
assert.strictEqual(r.status, 200);
assert.strictEqual(r.status, 200);
assert.ok(r.text.includes('Buying a home?') && r.text.includes('OpenVibe.Homes'));
assert.ok(r.text.includes('Buying a home?') && r.text.includes('OpenVibe.Homes'));
+ assert.ok(/<script type="application\/ld\+json">[^<]*"@type":"WebSite"[^<]*"name":"OpenVibe.Homes"/.test(r.text), 'the home says what the site is (JSON-LD)');
assert.ok(r.text.includes('<link rel="canonical" href="https://openvibe.homes/">'), 'its own canonical');
assert.ok(r.text.includes('<link rel="canonical" href="https://openvibe.homes/">'), 'its own canonical');
const rent = await t.get('/');
const rent = await t.get('/');
assert.ok(!rent.text.includes('Buying a home?'), 'Rent still serves Rent');
assert.ok(!rent.text.includes('Buying a home?'), 'Rent still serves Rent');