Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
naroat committed Nov 25, 2024
1 parent 2ac5802 commit 9a26bc9
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 49 deletions.
44 changes: 44 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,50 @@ const i18n = createI18n({
messages
})

// 添加一个获取favicon的函数
async function getFavicon(url) {
const faviconPaths = [
'/favicon.ico',
'/favicon.png',
'/apple-touch-icon.png',
'/apple-touch-icon-precomposed.png'
];

try {
// 首先尝试从HTML中获取favicon链接
const response = await fetch(url);
const html = await response.text();
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');

// 查找所有可能的favicon链接
const iconLinks = doc.querySelectorAll('link[rel*="icon"]');
if (iconLinks.length > 0) {
return iconLinks[0].href;
}

// 如果HTML中没有找到,尝试常见的favicon路径
const urlObj = new URL(url);
for (const path of faviconPaths) {
try {
const faviconUrl = urlObj.origin + path;
const faviconResponse = await fetch(faviconUrl);
if (faviconResponse.ok) {
return faviconUrl;
}
} catch (e) {
continue;
}
}

// 如果都失败了,可以返回一个默认图标
return '/default-favicon.png';
} catch (error) {
console.error('Error fetching favicon:', error);
return '/default-favicon.png';
}
}

const app = createApp({
setup() {
const url = ref('')
Expand Down
Binary file added favicon.ico
Binary file not shown.
50 changes: 1 addition & 49 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,12 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Favicon & Meta Info Fetcher - Get Website Icons and Metadata</title>

<link rel="icon" type="image/x-icon" href="favicon.ico">
<!-- SEO Meta Tags -->
<meta name="description" content="Free online tool to fetch favicons, meta descriptions, keywords and other metadata from any website. Simple, fast and easy to use.">
<meta name="keywords" content="favicon fetcher, meta info, website metadata, favicon finder, meta description, meta keywords, web tools">
<meta name="author" content="Favicon & Meta Info Fetcher">

<!-- Open Graph Meta Tags -->
<meta property="og:title" content="Favicon & Meta Info Fetcher - Get Website Icons and Metadata">
<meta property="og:description" content="Free online tool to fetch favicons, meta descriptions, keywords and other metadata from any website.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://your-domain.com">
<meta property="og:image" content="https://your-domain.com/og-image.png">

<!-- Twitter Card Meta Tags -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Favicon & Meta Info Fetcher">
<meta name="twitter:description" content="Free online tool to fetch favicons and metadata from any website">
<meta name="twitter:image" content="https://your-domain.com/twitter-image.png">

<!-- Canonical URL -->
<link rel="canonical" href="https://your-domain.com">

<!-- Favicon -->
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">

<!-- Additional Meta Tags -->
<meta name="robots" content="index, follow">
<meta name="theme-color" content="#8B5CF6">
Expand All @@ -43,33 +22,6 @@
<script src="https://unpkg.com/vue-i18n@9"></script>
<script src="https://cdn.tailwindcss.com"></script>
<script src="i18n.js"></script>

<!-- Structured Data -->
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebApplication",
"name": "Favicon & Meta Info Fetcher",
"description": "Free online tool to fetch favicons, meta descriptions, keywords and other metadata from any website.",
"url": "https://your-domain.com",
"applicationCategory": "WebTool",
"operatingSystem": "All",
"offers": {
"@type": "Offer",
"price": "0",
"priceCurrency": "USD"
},
"featureList": [
"Favicon extraction",
"Meta description retrieval",
"Keywords analysis",
"Multiple icon sizes support",
"One-click copying"
]
}
</script>

<!-- Google Analytics or other analytics code can be added here -->
</head>
<body class="bg-gray-100">
<div id="app"></div>
Expand Down
Binary file added logo-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9a26bc9

Please # to comment.