feat: enhance website SEO and add structured data (#49)

* feat(seo): enhance website SEO and add structured data

- Add comprehensive meta tags for SEO and social sharing
- Implement Schema.org structured data for news articles
- Create sitemap.xml for better search engine indexing
- Add og-image.svg for social media sharing
- Update footer with categorized news sources
- Remove redundant source links from news items
- Add Google Analytics placeholder

Meta tags:
- Add SEO meta tags (description, keywords, robots)
- Add Open Graph and Twitter Card meta tags
- Update website domain to newsnow.majiajue.com

Footer:
- Organize news sources into categories
- Add responsive grid layout
- Improve accessibility with proper link attributes
- Add dark mode support

* chore: update domain and deployment configuration

- Change domain from newsnow.majiajue.com to shishixinwen.news
- Update Google Analytics tracking ID
- Fix Windows deployment issues with cross-env
- Add build output directory to wrangler commands

Changes:
- Update meta tags and structured data with new domain
- Update sitemap.xml with new domain
- Add cross-env for cross-platform compatibility
- Update preview and deploy scripts with correct output path
- Configure Google Analytics with actual tracking ID
This commit is contained in:
majiajue 2025-01-19 15:38:29 +08:00 committed by GitHub
parent 3b843c39d3
commit f9dca9e20f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 205 additions and 35 deletions

View File

@ -1,14 +1,58 @@
<!doctype html>
<html lang="en">
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/icon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Elegant reading of real-time and hottest news" />
<!-- SEO Meta Tags -->
<meta name="description" content="NewsNow - 实时新闻聚合阅读器,汇集全球热点新闻,提供优雅的阅读体验" />
<meta name="keywords" content="新闻,科技新闻,实时新闻,新闻聚合,NewsNow" />
<meta name="author" content="NewsNow" />
<meta name="robots" content="index, follow" />
<!-- Open Graph Meta Tags -->
<meta property="og:title" content="NewsNow - 优雅的新闻聚合阅读器" />
<meta property="og:description" content="实时新闻聚合阅读器,汇集全球热点新闻,提供优雅的阅读体验" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://shishixinwen.news" />
<meta property="og:image" content="https://shishixinwen.news/og-image.svg" />
<!-- Twitter Card Meta Tags -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="NewsNow - 优雅的新闻聚合阅读器" />
<meta name="twitter:description" content="实时新闻聚合阅读器,汇集全球热点新闻,提供优雅的阅读体验" />
<meta name="twitter:image" content="https://shishixinwen.news/og-image.svg" />
<meta name="theme-color" content="#F14D42" />
<link rel="preload" href="/Baloo2-Bold.subset.ttf" as="font" type="font/ttf" crossorigin>
<link rel="apple-touch-icon" href="/apple-touch-icon.png" sizes="180x180" />
<!-- Schema.org markup for Google -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebSite",
"name": "NewsNow",
"url": "https://shishixinwen.news",
"description": "实时新闻聚合阅读器,汇集全球热点新闻,提供优雅的阅读体验",
"potentialAction": {
"@type": "SearchAction",
"target": "https://shishixinwen.news/search?q={search_term_string}",
"query-input": "required name=search_term_string"
}
}
</script>
<!-- Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-EL9HHYE5LC"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-EL9HHYE5LC');
</script>
<script>
function safeParseString(str) {
try {

View File

@ -16,8 +16,8 @@
"lint": "eslint",
"source": "tsx ./scripts/favicon.ts && tsx ./scripts/pinyin.ts",
"start": "node --env-file .env.server dist/output/server/index.mjs",
"preview": "CF_PAGES=1 pnpm run build && wrangler pages dev",
"deploy": "CF_PAGES=1 pnpm run build && wrangler pages deploy",
"preview": "cross-env CF_PAGES=1 npm run build && wrangler pages dev dist/output/public",
"deploy": "cross-env CF_PAGES=1 npm run build && wrangler pages deploy dist/output/public",
"typecheck": "tsc --noEmit -p tsconfig.node.json && tsc --noEmit -p tsconfig.app.json",
"release": "bumpp",
"prepare": "simple-git-hooks",
@ -52,6 +52,7 @@
"md5": "^2.3.0",
"ofetch": "^1.4.1",
"overlayscrollbars": "^2.10.0",
"pnpm": "^9.15.4",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-use": "^17.5.1",
@ -74,6 +75,7 @@
"@unocss/rule-utils": "^0.63.4",
"@vitejs/plugin-react-swc": "^3.7.1",
"bumpp": "^9.7.1",
"cross-env": "^7.0.3",
"dotenv": "^16.4.5",
"eslint": "^9.12.0",
"eslint-plugin-react-hooks": "^5.1.0-rc-77f43893-20241010",
@ -113,5 +115,8 @@
},
"lint-staged": {
"*": "eslint --fix"
},
"volta": {
"node": "22.12.0"
}
}

6
public/og-image.svg Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="1200" height="630" viewBox="0 0 1200 630" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="1200" height="630" fill="#F14D42"/>
<text x="50%" y="45%" text-anchor="middle" font-family="Arial, sans-serif" font-size="72" fill="white" font-weight="bold">NewsNow</text>
<text x="50%" y="60%" text-anchor="middle" font-family="Arial, sans-serif" font-size="36" fill="white">实时新闻聚合阅读器</text>
</svg>

After

Width:  |  Height:  |  Size: 484 B

16
public/sitemap.xml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://shishixinwen.news/</loc>
<lastmod>2025-01-18</lastmod>
<changefreq>always</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://shishixinwen.news/search</loc>
<lastmod>2025-01-18</lastmod>
<changefreq>always</changefreq>
<priority>0.8</priority>
</url>
<!-- 添加其他重要页面 -->
</urlset>

View File

@ -261,28 +261,52 @@ function NewsListHot({ items }: { items: NewsItem[] }) {
function NewsListTimeLine({ items }: { items: NewsItem[] }) {
const { width } = useWindowSize()
return (
<ol className="border-s border-neutral-400/50 flex flex-col ml-1">
{items?.map(item => (
<li key={item.id} className="flex flex-col">
<span className="flex items-center gap-1 text-neutral-400/50 ml--1px">
<span className="">-</span>
<span className="text-xs text-neutral-400/80">
{(item.pubDate || item?.extra?.date) && <NewsUpdatedTime date={(item.pubDate || item?.extra?.date)!} />}
<>
<script type="application/ld+json">
{JSON.stringify({
"@context": "https://schema.org",
"@type": "ItemList",
"itemListElement": items.map((item, index) => ({
"@type": "ListItem",
"position": index + 1,
"item": {
"@type": "NewsArticle",
"headline": item.title,
"url": width < 768 ? item.mobileUrl || item.url : item.url,
"datePublished": item.pubDate || item?.extra?.date,
"publisher": {
"@type": "Organization",
"name": item.source || "NewsNow",
"url": item.sourceUrl || "https://shishixinwen.news",
},
},
})),
})}
</script>
<ol className="border-s border-neutral-400/50 flex flex-col ml-1">
{items?.map(item => (
<li key={`${item.id}-${item.pubDate || item?.extra?.date || ""}`} className="flex flex-col">
<span className="flex items-center gap-1 text-neutral-400/50 ml--1px">
<span className="">-</span>
<span className="text-xs text-neutral-400/80">
{(item.pubDate || item?.extra?.date) && <NewsUpdatedTime date={(item.pubDate || item?.extra?.date)!} />}
</span>
<span className="text-xs text-neutral-400/80">
<ExtraInfo item={item} />
</span>
</span>
<span className="text-xs text-neutral-400/80">
<ExtraInfo item={item} />
</span>
</span>
<a
className={$("ml-2 px-1 hover:bg-neutral-400/10 rounded-md visited:(text-neutral-400/80)")}
href={width < 768 ? item.mobileUrl || item.url : item.url}
title={item.extra?.hover}
target="_blank"
>
{item.title}
</a>
</li>
))}
</ol>
<a
className={$("ml-2 px-1 hover:bg-neutral-400/10 rounded-md visited:(text-neutral-400/80)")}
href={width < 768 ? item.mobileUrl || item.url : item.url}
title={item.extra?.hover}
target="_blank"
rel="noopener noreferrer"
>
{item.title}
</a>
</li>
))}
</ol>
</>
)
}

View File

@ -1,13 +1,88 @@
export function Footer() {
const sources = [
{
category: "科技资讯",
links: [
{ name: "Hacker News", url: "https://news.ycombinator.com" },
{ name: "Product Hunt", url: "https://www.producthunt.com" },
{ name: "GitHub", url: "https://github.com/trending" },
{ name: "IT之家", url: "https://www.ithome.com" },
{ name: "V2EX", url: "https://v2ex.com" },
{ name: "Linux中国", url: "https://linux.cn" },
{ name: "Solidot", url: "https://www.solidot.org" },
],
},
{
category: "社交媒体",
links: [
{ name: "微博", url: "https://weibo.com" },
{ name: "知乎", url: "https://zhihu.com" },
{ name: "哔哩哔哩", url: "https://bilibili.com" },
{ name: "抖音", url: "https://douyin.com" },
{ name: "快手", url: "https://kuaishou.com" },
{ name: "贴吧", url: "https://tieba.baidu.com" },
{ name: "酷安", url: "https://coolapk.com" },
],
},
{
category: "新闻资讯",
links: [
{ name: "36氪", url: "https://36kr.com" },
{ name: "澎湃新闻", url: "https://thepaper.cn" },
{ name: "今日头条", url: "https://toutiao.com" },
{ name: "参考消息", url: "http://www.cankaoxiaoxi.com" },
{ name: "联合早报", url: "https://www.zaobao.com" },
{ name: "卫星通讯社", url: "http://sputniknews.cn" },
],
},
{
category: "财经资讯",
links: [
{ name: "华尔街见闻", url: "https://wallstreetcn.com" },
{ name: "雪球", url: "https://xueqiu.com" },
{ name: "格隆汇", url: "https://gelonghui.com" },
{ name: "金十数据", url: "https://jin10.com" },
{ name: "FastBull", url: "https://fastbull.cn" },
],
},
]
return (
<>
<a href={`${Homepage}/LICENCE`} target="_blank">MIT LICENCE</a>
<span>
<span>NewsNow © 2024 By </span>
<a href={Author.url} target="_blank">
{Author.name}
</a>
</span>
</>
<footer className="mt-8 pb-4 text-sm text-neutral-400">
<div className="max-w-7xl mx-auto px-4">
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-8 mb-8">
{sources.map(category => (
<div key={category.category}>
<h3 className="font-medium mb-4 text-neutral-500">{category.category}</h3>
<ul className="space-y-2">
{category.links.map(link => (
<li key={link.name}>
<a
href={link.url}
target="_blank"
rel="noopener noreferrer"
className="hover:text-neutral-600 transition-colors"
>
{link.name}
</a>
</li>
))}
</ul>
</div>
))}
</div>
<div className="text-center pt-4 border-t border-neutral-200 dark:border-neutral-800">
<span>NewsNow 2025 By </span>
<a
href="https://github.com/majiajue/newsnow"
target="_blank"
rel="noopener noreferrer"
className="hover:text-neutral-600 transition-colors"
>
majiajue
</a>
</div>
</div>
</footer>
)
}