mirror of
https://github.com/labring/FastGPT.git
synced 2026-03-20 01:06:42 +08:00
* cloud doc * doc refactor * doc move * seo * remove doc * yml * doc * fix: tsconfig * fix: tsconfig
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
import type { Article, BreadcrumbList, WithContext } from 'schema-dts';
|
|
|
|
export function generateArticleSchema(params: {
|
|
title: string;
|
|
description: string;
|
|
url: string;
|
|
dateModified?: Date;
|
|
lang: string;
|
|
}): WithContext<Article> {
|
|
const { title, description, url, dateModified, lang } = params;
|
|
|
|
return {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'Article',
|
|
headline: title,
|
|
description,
|
|
url,
|
|
inLanguage: lang,
|
|
dateModified: dateModified?.toISOString(),
|
|
author: {
|
|
'@type': 'Organization',
|
|
name: 'Labring',
|
|
url: 'https://github.com/labring'
|
|
},
|
|
publisher: {
|
|
'@type': 'Organization',
|
|
name: 'FastGPT',
|
|
logo: {
|
|
'@type': 'ImageObject',
|
|
url: 'https://doc.fastgpt.io/logo.svg'
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
export function generateBreadcrumbSchema(params: {
|
|
items: Array<{ name: string; url: string }>;
|
|
}): WithContext<BreadcrumbList> {
|
|
const { items } = params;
|
|
|
|
return {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'BreadcrumbList',
|
|
itemListElement: items.map((item, index) => ({
|
|
'@type': 'ListItem',
|
|
position: index + 1,
|
|
name: item.name,
|
|
item: item.url
|
|
}))
|
|
};
|
|
}
|