mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-02-24 01:09:41 +01:00
chore(docs): Improve SEO icon detail pages (#4040)
* improve-seo-website * Add some description texts
This commit is contained in:
@@ -22,6 +22,7 @@ export default eventHandler((event) => {
|
||||
const height = getQuery(event).height || undefined;
|
||||
const color = getQuery(event).color || undefined;
|
||||
const strokeWidth = getQuery(event).strokeWidth || undefined;
|
||||
const background = getQuery(event).background || undefined;
|
||||
|
||||
const LucideIcon = createLucideIcon(params.iconName, iconNode);
|
||||
|
||||
@@ -32,6 +33,7 @@ export default eventHandler((event) => {
|
||||
height,
|
||||
color: color ? `#${color}` : undefined,
|
||||
strokeWidth,
|
||||
style: background ? { background } : undefined,
|
||||
}),
|
||||
),
|
||||
).toString('utf8');
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { fileURLToPath, URL } from 'node:url';
|
||||
import { defineConfig } from 'vitepress';
|
||||
import sidebar from './sidebar';
|
||||
import getStructuredData from './getStructuredData';
|
||||
|
||||
const title = 'Lucide';
|
||||
const socialTitle = 'Lucide Icons';
|
||||
@@ -151,8 +152,36 @@ export default defineConfig({
|
||||
},
|
||||
],
|
||||
],
|
||||
async transformPageData(pageData) {
|
||||
if (
|
||||
pageData.relativePath.startsWith('icons/') &&
|
||||
!pageData.relativePath.startsWith('icons/lab/') &&
|
||||
pageData.params?.name
|
||||
) {
|
||||
const iconName = pageData.params.name;
|
||||
pageData.title = `${iconName} icon details`;
|
||||
|
||||
const taggedAs = pageData.params?.tags?.length
|
||||
? `Tagged as: ${pageData.params.tags.join(', ')}.`
|
||||
: '';
|
||||
const categorizedIn = pageData.params?.category?.length
|
||||
? `Categorized in: ${pageData.params.category.join(', ')}.`
|
||||
: '';
|
||||
|
||||
pageData.description =
|
||||
`Details and related icons for ${iconName} icon. ${taggedAs} ${categorizedIn}`.trim();
|
||||
|
||||
const structuredData = await getStructuredData(iconName, pageData);
|
||||
|
||||
pageData.frontmatter.head ??= [];
|
||||
pageData.frontmatter.head.push([
|
||||
'script',
|
||||
{ type: 'application/ld+json' },
|
||||
JSON.stringify(structuredData),
|
||||
]);
|
||||
}
|
||||
},
|
||||
themeConfig: {
|
||||
// https://vitepress.dev/reference/default-theme-config
|
||||
logo: {
|
||||
light: '/logo.light.svg',
|
||||
dark: '/logo.dark.svg',
|
||||
|
||||
46
docs/.vitepress/getStructuredData.ts
Normal file
46
docs/.vitepress/getStructuredData.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { PageData } from 'vitepress';
|
||||
|
||||
export default async function getStructuredData(iconName: string, pageData: PageData) {
|
||||
const url = `https://lucide.dev/icons/${iconName}`;
|
||||
|
||||
return {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'WebPage',
|
||||
'@id': url,
|
||||
name: pageData.title,
|
||||
description: pageData.description,
|
||||
url,
|
||||
inLanguage: 'en',
|
||||
isPartOf: {
|
||||
'@type': 'WebSite',
|
||||
name: 'Lucide Icons',
|
||||
url: 'https://lucide.dev',
|
||||
},
|
||||
breadcrumb: {
|
||||
'@type': 'BreadcrumbList',
|
||||
itemListElement: [
|
||||
{ '@type': 'ListItem', position: 1, name: 'Icons', item: 'https://lucide.dev/icons' },
|
||||
{ '@type': 'ListItem', position: 2, name: iconName, item: url },
|
||||
],
|
||||
},
|
||||
mainEntity: {
|
||||
'@type': 'ImageObject',
|
||||
'@id': `${url}#icon`,
|
||||
name: iconName,
|
||||
// TODO: Add support for description extraction from icon metadata
|
||||
// description: 'An ...SVG icon from the Lucide icon set.',
|
||||
contentUrl: `https://lucide.dev/api/icons/${iconName}}?width=24&height=24&background=white`,
|
||||
thumbnailUrl: `https://lucide.dev/api/icons/${iconName}}?width=256&height=256&background=white`,
|
||||
encodingFormat: 'image/svg+xml',
|
||||
keywords: pageData.params?.tags,
|
||||
width: 24,
|
||||
height: 24,
|
||||
creator: {
|
||||
'@type': 'Organization',
|
||||
name: 'Lucide Icons',
|
||||
},
|
||||
datePublished: pageData?.params?.createdRelease?.date,
|
||||
dateModified: pageData?.params?.changedRelease?.date,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
---
|
||||
aside: false
|
||||
title: Contributing to Lucide
|
||||
description: Guidelines and instructions for contributing to the Lucide project.
|
||||
---
|
||||
|
||||
<!--@include: ../CONTRIBUTING.md -->
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
title: Categories
|
||||
description: Explore Lucide icons organized into various categories for easier browsing.
|
||||
layout: page
|
||||
outline: 2
|
||||
outlineTitle: Categories
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
title: Icons
|
||||
description: Browse all Lucide icons.
|
||||
layout: page
|
||||
outline: 2
|
||||
outlineTitle: Categories
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
title: License
|
||||
description: Review the licensing terms for using Lucide icons and resources.
|
||||
aside: false
|
||||
editLink: false
|
||||
---
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
title: Packages
|
||||
description: Discover the various packages available in the Lucide ecosystem.
|
||||
layout: page
|
||||
outline: 2
|
||||
outlineTitle: Packages
|
||||
|
||||
Reference in New Issue
Block a user