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)
Changes
@@@ -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>@@@ -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);
@@ -234,8 +234,11 @@ ${plan.notes.map((n) => html`<p class="muted small">${n}</p>`)}`;
@@ -234,8 +234,11 @@ ${plan.notes.map((n) => html`<p class="muted small">${n}</p>`)}`;
let problem = null;
let problem = null;
try { plan = planMeals(spec); } catch (err) { problem = err && err.message ? err.message : 'That plan could not be made.'; }
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);
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, {
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.',
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],
crumbs: [{ label: 'Meal plan' }], styles: [showcase.STYLESHEET],
body: html`<h1>Plan meals</h1>
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>
<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>
@@ -54,6 +54,15 @@ const foods = require('../server/food/foods');
@@ -54,6 +54,15 @@ const foods = require('../server/food/foods');
assert.strictEqual(missing.json().code, 'food.food.not_found');
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 () => {
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');
const list = await t.get('/foods');
assert.strictEqual(list.status, 200);
assert.strictEqual(list.status, 200);