// workflow step: seo — score the post on a few SEO heuristics. Runs in PARALLEL // with `enrich`. Output { score, warnings } (advisory; doesn't block publish). let b = ctx.request.body; let post = docs::collection("posts").get(b.post_id); let d = post.data; let warnings = []; let score = 100; if d.tags == () || d.tags.len() == 0 { warnings.push("no tags"); score -= 30; } let tlen = if d.title == () { 0 } else { d.title.len() }; if tlen < 10 { warnings.push("title is short (<10 chars)"); score -= 20; } if tlen > 70 { warnings.push("title is long (>70 chars)"); score -= 10; } if score < 0 { score = 0; } #{ score: score, warnings: warnings }