improve LD config
This commit is contained in:
parent
18232ee276
commit
4aebccbc7b
2 changed files with 76 additions and 13 deletions
|
@ -1,12 +1,17 @@
|
||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load contact_tags %}
|
{% load contact_tags %}
|
||||||
|
{% load json_ld_tags %}
|
||||||
|
|
||||||
{% block title %}Managed {{ offering.service.name }} on {{ offering.cloud_provider.name }}{% endblock %}
|
{% block title %}Managed {{ offering.service.name }} on {{ offering.cloud_provider.name }}{% endblock %}
|
||||||
|
|
||||||
{% block extra_js %}
|
{% block extra_js %}
|
||||||
<script defer src="{% static "js/price-calculator.js" %}"></script>
|
<script defer src="{% static "js/price-calculator.js" %}"></script>
|
||||||
<link rel="stylesheet" type="text/css" href='{% static "css/price-calculator.css" %}'>
|
<link rel="stylesheet" type="text/css" href='{% static "css/price-calculator.css" %}'>
|
||||||
|
|
||||||
|
<!-- JSON-LD Structured Data -->
|
||||||
|
{% json_ld_structured_data %}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
/* Subtle styling for the best plan */
|
/* Subtle styling for the best plan */
|
||||||
.card.border-success.border-2 {
|
.card.border-success.border-2 {
|
||||||
|
|
|
@ -209,7 +209,7 @@ def json_ld_structured_data(context):
|
||||||
data = {
|
data = {
|
||||||
"@context": "https://schema.org",
|
"@context": "https://schema.org",
|
||||||
"@type": "Product",
|
"@type": "Product",
|
||||||
"name": f"{offering.service.name} on {offering.cloud_provider.name}",
|
"name": f"Managed {offering.service.name} on {offering.cloud_provider.name}",
|
||||||
"description": offering.description or offering.service.description,
|
"description": offering.description or offering.service.description,
|
||||||
"url": offering_url,
|
"url": offering_url,
|
||||||
"category": "Cloud Service",
|
"category": "Cloud Service",
|
||||||
|
@ -224,18 +224,76 @@ def json_ld_structured_data(context):
|
||||||
|
|
||||||
# Add offers if available
|
# Add offers if available
|
||||||
if hasattr(offering, "plans") and offering.plans.exists():
|
if hasattr(offering, "plans") and offering.plans.exists():
|
||||||
data["offers"] = {
|
# Get all plans with pricing
|
||||||
"@type": "AggregateOffer",
|
plans_with_prices = offering.plans.filter(plan_prices__isnull=False).distinct()
|
||||||
"availability": "https://schema.org/InStock",
|
|
||||||
"offerCount": offering.plans.count(),
|
if plans_with_prices.exists():
|
||||||
"seller": {
|
# Create individual offers for each plan
|
||||||
"@type": "Organization",
|
offers = []
|
||||||
"name": offering.cloud_provider.name,
|
all_prices = []
|
||||||
"url": request.build_absolute_uri(
|
|
||||||
offering.cloud_provider.get_absolute_url()
|
for plan in plans_with_prices:
|
||||||
),
|
plan_prices = plan.plan_prices.all()
|
||||||
},
|
if plan_prices.exists():
|
||||||
}
|
first_price = plan_prices.first()
|
||||||
|
all_prices.extend([p.amount for p in plan_prices])
|
||||||
|
|
||||||
|
offer = {
|
||||||
|
"@type": "Offer",
|
||||||
|
"name": plan.name,
|
||||||
|
"price": str(first_price.amount),
|
||||||
|
"priceCurrency": first_price.currency,
|
||||||
|
"availability": "https://schema.org/InStock",
|
||||||
|
"url": offering_url + "#plan-order-form",
|
||||||
|
"seller": {
|
||||||
|
"@type": "Organization",
|
||||||
|
"name": "VSHN"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
offers.append(offer)
|
||||||
|
|
||||||
|
# Add aggregate offer with all individual offers
|
||||||
|
data["offers"] = {
|
||||||
|
"@type": "AggregateOffer",
|
||||||
|
"availability": "https://schema.org/InStock",
|
||||||
|
"offerCount": len(offers),
|
||||||
|
"offers": offers,
|
||||||
|
"seller": {
|
||||||
|
"@type": "Organization",
|
||||||
|
"name": "VSHN"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add lowPrice, highPrice and priceCurrency if we have prices
|
||||||
|
if all_prices:
|
||||||
|
data["offers"]["lowPrice"] = str(min(all_prices))
|
||||||
|
data["offers"]["highPrice"] = str(max(all_prices))
|
||||||
|
# Use the currency from the first plan's first price
|
||||||
|
first_plan_with_prices = plans_with_prices.first()
|
||||||
|
first_currency = first_plan_with_prices.plan_prices.first().currency
|
||||||
|
data["offers"]["priceCurrency"] = first_currency
|
||||||
|
|
||||||
|
# Note: aggregateRating and review fields are not included as this is a B2B
|
||||||
|
# service marketplace without a review system. These could be added in the future
|
||||||
|
# if customer reviews/ratings are implemented.
|
||||||
|
# Example structure for future implementation:
|
||||||
|
# if hasattr(offering, 'reviews') and offering.reviews.exists():
|
||||||
|
# data["aggregateRating"] = {
|
||||||
|
# "@type": "AggregateRating",
|
||||||
|
# "ratingValue": "4.5",
|
||||||
|
# "reviewCount": "10"
|
||||||
|
# }
|
||||||
|
else:
|
||||||
|
# No pricing available, just basic offer info
|
||||||
|
data["offers"] = {
|
||||||
|
"@type": "AggregateOffer",
|
||||||
|
"availability": "https://schema.org/InStock",
|
||||||
|
"offerCount": offering.plans.count(),
|
||||||
|
"seller": {
|
||||||
|
"@type": "Organization",
|
||||||
|
"name": "VSHN"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Default to organization data if no specific page type matches
|
# Default to organization data if no specific page type matches
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue