Skip to content

Commit d7c4d81

Browse files
补全了 FAQ JSON-LD 字段
X-Lovable-Edit-ID: edt-d7daea6d-c8b0-4958-b3fa-07ff667d8308 Co-authored-by: 0xPabloLI <77742839+0xPabloLI@users.noreply.github.com>
2 parents f8f3276 + 572bb0e commit d7c4d81

1 file changed

Lines changed: 30 additions & 8 deletions

File tree

‎src/pages/DefiYieldTracker.tsx‎

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const FAQS: { q: string; a: string }[] = [
3333
},
3434
{
3535
q: 'What are DeFi lending rates and how are they set?',
36-
a: 'DeFi lending rates are set algorithmically based on pool utilization — the ratio of borrowed assets to supplied assets. When utilization is low, rates stay moderate; when liquidity runs tight, rates spike sharply to attract new deposits. Aave governance sets each pool\'s base rate, slope parameters, and optimal utilization point, which together define the rate curve.',
36+
a: "DeFi lending rates are set algorithmically based on pool utilization — the ratio of borrowed assets to supplied assets. When utilization is low, rates stay moderate; when liquidity runs tight, rates spike sharply to attract new deposits. Aave governance sets each pool's base rate, slope parameters, and optimal utilization point, which together define the rate curve.",
3737
},
3838
{
3939
q: 'How do I track my DeFi portfolio on Aave?',
@@ -49,24 +49,46 @@ const FAQS: { q: string; a: string }[] = [
4949
},
5050
];
5151

52+
function faqSlug(q: string) {
53+
return q
54+
.toLowerCase()
55+
.replace(/[^a-z0-9\s-]/g, '')
56+
.trim()
57+
.replace(/\s+/g, '-')
58+
.substring(0, 64);
59+
}
5260

5361
const jsonLd = {
5462
'@context': 'https://schema.org',
5563
'@graph': [
5664
{
5765
'@type': 'WebPage',
66+
'@id': CANONICAL,
5867
name: TITLE,
5968
description: DESCRIPTION,
6069
url: CANONICAL,
61-
isPartOf: { '@type': 'WebSite', name: 'AAVE APY', url: `${SITE_ORIGIN}/` },
70+
isPartOf: { '@type': 'WebSite', '@id': `${SITE_ORIGIN}/`, name: 'AAVE APY', url: `${SITE_ORIGIN}/` },
71+
inLanguage: 'en',
6272
},
6373
{
6474
'@type': 'FAQPage',
65-
mainEntity: FAQS.map((f) => ({
66-
'@type': 'Question',
67-
name: f.q,
68-
acceptedAnswer: { '@type': 'Answer', text: f.a },
69-
})),
75+
'@id': `${CANONICAL}#faq`,
76+
url: CANONICAL,
77+
mainEntity: FAQS.map((f) => {
78+
const slug = faqSlug(f.q);
79+
return {
80+
'@type': 'Question',
81+
'@id': `${CANONICAL}#${slug}`,
82+
url: `${CANONICAL}#${slug}`,
83+
name: f.q,
84+
acceptedAnswer: {
85+
'@type': 'Answer',
86+
'@id': `${CANONICAL}#${slug}-answer`,
87+
text: f.a,
88+
inLanguage: 'en',
89+
},
90+
};
91+
}),
7092
},
7193
],
7294
};
@@ -220,7 +242,7 @@ const DefiYieldTracker = () => {
220242
</h2>
221243
<dl className="space-y-5">
222244
{FAQS.map((f) => (
223-
<div key={f.q}>
245+
<div key={f.q} id={faqSlug(f.q)}>
224246
<dt className="font-medium text-foreground">{f.q}</dt>
225247
<dd className="mt-1 text-muted-foreground leading-relaxed">{f.a}</dd>
226248
</div>

0 commit comments

Comments
 (0)