Skip to content

Commit cb91c3a

Browse files
committed
Add featured items to seo things
1 parent 3be1fbd commit cb91c3a

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

html/place.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ <h1 class="name">{{ name }}</h1>
116116
<p><b class="sgfi">Something Going For It</b></p>
117117
{% endif %}
118118
{% if food_image_path %}
119-
<img src="{{ food_image_path }}" alt="Vegan {{ cuisine }} food at {{ name }} in {{ area }}, San Francisco Bay Area" class="food-image">
119+
<img src="{{ food_image_path }}" alt="{{ alt_text }}" class="food-image">
120120
{% endif %}
121121
<h3 class="notes">Remarks</h3>
122122
{{ content }}

scripts/build.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,17 @@ def format_title(meta):
168168
def format_description(meta):
169169
return f'Read our review on {meta["name"]} at {meta["address"]} in {meta["area"]}, and more tasty vegan {meta["cuisine"]} food in the San Francisco Bay Area from V.I.L.F!'
170170

171+
def format_description_with_dishes(meta, md):
172+
"""Generate enhanced meta description with specific dishes mentioned"""
173+
# Extract dishes marked with ** from review text
174+
dishes = re.findall(r'\*\*(.*?)\*\*', md)
175+
176+
if dishes:
177+
dishes_text = ", ".join(dishes[:2]) # Max 2 dishes for meta description
178+
return f'Read our review on {meta["name"]} featuring {dishes_text} at {meta["address"]} in {meta["area"]}, and more tasty vegan {meta["cuisine"]} food in the San Francisco Bay Area from V.I.L.F!'
179+
else:
180+
return f'Read our review on {meta["name"]} at {meta["address"]} in {meta["area"]}, and more tasty vegan {meta["cuisine"]} food in the San Francisco Bay Area from V.I.L.F!'
181+
171182
def format_phone_number(meta):
172183
if meta["phone"] is None:
173184
return
@@ -193,6 +204,17 @@ def format_visited(visited):
193204
def format_blurb(md):
194205
return " ".join(plain(re.sub(r"\s+", " ", md.strip())).split(" ")[:50]) + "..."
195206

207+
def format_alt_text(meta, md):
208+
"""Generate enhanced alt text with specific dishes mentioned"""
209+
base_alt = f"Vegan {meta['cuisine']} food at {meta['name']} in {meta['area']}, San Francisco Bay Area"
210+
211+
# Extract dishes marked with ** from review text
212+
dishes = re.findall(r'\*\*(.*?)\*\*', md)
213+
if dishes:
214+
dishes_text = ", ".join(dishes[:3]) # Max 3 dishes
215+
return f"{base_alt} featuring {dishes_text}"
216+
return base_alt
217+
196218
def get_fp_food_image(slug):
197219
static_fp = Path(f"img/food/{slug}.jpg")
198220
return (
@@ -237,12 +259,13 @@ def get_fp_food_thumb(slug):
237259
)
238260
html = markdown(md.strip())
239261
meta["blurb"] = format_blurb(md)
262+
meta["alt_text"] = format_alt_text(meta, md)
240263
meta["food_image_path"] = get_fp_food_image(slug)
241264
meta["food_thumb_path"] = get_fp_food_thumb(slug)
242265
rendered = place_template.render(
243266
**meta,
244267
title=format_title(meta),
245-
description=format_description(meta),
268+
description=format_description_with_dishes(meta, md),
246269
taste_html=rating_html(meta["taste"], taste_labels),
247270
value_html=rating_html(meta["value"], value_labels),
248271
drinks_html=boolean_html(meta["drinks"]),

0 commit comments

Comments
 (0)