openvibers/openvibe.food Commits

The meal planner is in search: /plan says index (it was noindex by default while the sitemap listed it), every variant canonical to /plan (#66)

OP OpenVibers committed 24 days ago · e421502dbf · 2 files, +12 −0

Changes

ddiff --git a/server/http/pages.js b/server/http/pages.js
iindex b8f2fcc..6348efa 100644
---- a/server/http/pages.js
++++ b/server/http/pages.js
@@@ -234,8 +234,11 @@ ${plan.notes.map((n) => html`<p class="muted small">${n}</p>`)}`;
let problem = null;
try { plan = planMeals(spec); } catch (err) { problem = err && err.message ? err.message : 'That plan could not be made.'; }
const savedId = str(req.query.saved, 40);
++ // A public tool page in search (it was noindex by default while the sitemap listed it); every ?people=&days=
++ // variant names /plan as canonical (layout.js drops the query).
page(req, res, {
title: 'Meal plan', description: 'A budget meal plan with a shopping list and an estimated cost, from the OpenVibe.Food food list.',
++ index: true, cache: signedIn(req) ? null : PUBLIC_CACHE,
crumbs: [{ label: 'Meal plan' }], styles: [showcase.STYLESHEET],
body: html`<h1>Plan meals</h1>
<p class="lede">It buys one item from each of the six food groups first, cheapest per serving, then fills up with the best calories per dollar. Deterministic: the same numbers always give the same plan.</p>
ddiff --git a/test/foods.test.js b/test/foods.test.js
iindex ceaa64e..060bf1a 100644
---- a/test/foods.test.js
++++ b/test/foods.test.js
@@@ -54,6 +54,15 @@ const foods = require('../server/food/foods');
assert.strictEqual(missing.json().code, 'food.food.not_found');
});
++ await check('the meal planner is in search: indexable, every ?people=&days= variant canonical to /plan', async () => {
++ const r = await t.get('/plan?people=4&days=5');
++ assert.strictEqual(r.status, 200);
++ assert.match(r.text, /<meta name="robots" content="index, follow">/);
++ assert.match(r.text, /<link rel="canonical" href="[^"]*\/plan">/);
++ const map = await t.get('/sitemap.xml');
++ assert.match(map.text, /<loc>[^<]*\/plan<\/loc>/, 'and the sitemap lists it');
++ });
++
await check('the /foods page and one food page render server-side, per serving and per 100 g', async () => {
const list = await t.get('/foods');
assert.strictEqual(list.status, 200);