:magify: Improve SEO
This commit is contained in:
parent
15e1b3971f
commit
1bc50aecc5
@ -7,9 +7,20 @@ import icon from 'astro-icon'
|
|||||||
|
|
||||||
import mdx from '@astrojs/mdx'
|
import mdx from '@astrojs/mdx'
|
||||||
|
|
||||||
|
import sitemap from '@astrojs/sitemap'
|
||||||
|
|
||||||
// https://astro.build/config
|
// https://astro.build/config
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
integrations: [tailwind(), icon(), mdx()],
|
site: 'https://solsynth.dev',
|
||||||
|
integrations: [
|
||||||
|
tailwind(),
|
||||||
|
icon(),
|
||||||
|
mdx(),
|
||||||
|
sitemap({
|
||||||
|
xslURL: '/sitemap.xsl',
|
||||||
|
i18n: { defaultLocale: 'en', locales: { en: 'en-US', 'zh-cn': 'zh-CN' } },
|
||||||
|
}),
|
||||||
|
],
|
||||||
prefetch: true,
|
prefetch: true,
|
||||||
i18n: {
|
i18n: {
|
||||||
locales: ['en', 'zh-cn'],
|
locales: ['en', 'zh-cn'],
|
||||||
|
@ -10,11 +10,13 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/mdx": "^4.0.2",
|
"@astrojs/mdx": "^4.0.2",
|
||||||
|
"@astrojs/sitemap": "^3.2.1",
|
||||||
"@astrojs/tailwind": "^5.1.3",
|
"@astrojs/tailwind": "^5.1.3",
|
||||||
"@iconify-json/material-symbols": "^1.2.10",
|
"@iconify-json/material-symbols": "^1.2.10",
|
||||||
"@iconify-json/simple-icons": "^1.2.16",
|
"@iconify-json/simple-icons": "^1.2.16",
|
||||||
"astro": "^5.0.5",
|
"astro": "^5.0.5",
|
||||||
"astro-icon": "^1.1.4",
|
"astro-icon": "^1.1.4",
|
||||||
|
"astro-seo": "^0.8.4",
|
||||||
"marked": "^15.0.4",
|
"marked": "^15.0.4",
|
||||||
"sanitize-html": "^2.13.1",
|
"sanitize-html": "^2.13.1",
|
||||||
"tailwindcss": "^3.4.16"
|
"tailwindcss": "^3.4.16"
|
||||||
|
4
public/robots.txt
Normal file
4
public/robots.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
User-agent: *
|
||||||
|
Allow: /
|
||||||
|
|
||||||
|
Sitemap: https://solsynth.dev/sitemap-index.xml
|
@ -1,6 +1,4 @@
|
|||||||
---
|
---
|
||||||
export const prerender = false
|
|
||||||
|
|
||||||
import { Image } from 'astro:assets'
|
import { Image } from 'astro:assets'
|
||||||
|
|
||||||
import { version } from '../../package.json'
|
import { version } from '../../package.json'
|
||||||
@ -10,9 +8,11 @@ import { getRelativeLocaleUrl } from 'astro:i18n'
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
title?: string
|
title?: string
|
||||||
|
trailingTitle?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const { title } = Astro.props
|
let { title, trailingTitle } = Astro.props
|
||||||
|
if(trailingTitle == null) trailingTitle = 'Solsynth LLC'
|
||||||
|
|
||||||
const locale = Astro.currentLocale ?? 'en'
|
const locale = Astro.currentLocale ?? 'en'
|
||||||
---
|
---
|
||||||
@ -23,7 +23,8 @@ const locale = Astro.currentLocale ?? 'en'
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width" />
|
<meta name="viewport" content="width=device-width" />
|
||||||
<link rel="icon" type="image/png" href="/favicon.png" />
|
<link rel="icon" type="image/png" href="/favicon.png" />
|
||||||
<title>{title ? `${title} | Solsynth LLC` : 'Solsynth LLC'}</title>
|
<link rel="sitemap" href="/sitemap-index.xml" />
|
||||||
|
<title>{title ? `${title} | ${trailingTitle}` : trailingTitle}</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="navbar backdrop-blur fixed top-0 left-0 right-0 z-10">
|
<div class="navbar backdrop-blur fixed top-0 left-0 right-0 z-10">
|
||||||
@ -41,16 +42,7 @@ const locale = Astro.currentLocale ?? 'en'
|
|||||||
|
|
||||||
<div class="flex-1 flex justify-end">
|
<div class="flex-1 flex justify-end">
|
||||||
<ul class="menu menu-horizontal px-1">
|
<ul class="menu menu-horizontal px-1">
|
||||||
<li><a>Link</a></li>
|
<li><a href="/posts">Explore</a></li>
|
||||||
<li>
|
|
||||||
<details>
|
|
||||||
<summary>Parent</summary>
|
|
||||||
<ul class="bg-base-100 rounded-t-none p-2">
|
|
||||||
<li><a>Link 1</a></li>
|
|
||||||
<li><a>Link 2</a></li>
|
|
||||||
</ul>
|
|
||||||
</details>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -3,6 +3,7 @@ export const prerender = false
|
|||||||
|
|
||||||
import sanitizeHtml from 'sanitize-html'
|
import sanitizeHtml from 'sanitize-html'
|
||||||
import { Icon } from 'astro-icon/components'
|
import { Icon } from 'astro-icon/components'
|
||||||
|
import {SEO} from 'astro-seo'
|
||||||
import { marked } from 'marked'
|
import { marked } from 'marked'
|
||||||
|
|
||||||
import Layout from '@/layouts/Layout.astro'
|
import Layout from '@/layouts/Layout.astro'
|
||||||
@ -28,7 +29,33 @@ const content = sanitizeHtml(rawContent)
|
|||||||
const attachments = await fetchAttachmentMeta(data.body.attachments)
|
const attachments = await fetchAttachmentMeta(data.body.attachments)
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout title={data.body?.title ? data.body.title : `Post #${data.id}`}>
|
<head>
|
||||||
|
<SEO
|
||||||
|
title={data.body?.title ? data.body.title : `Post #${data.id}`}
|
||||||
|
description={data.body?.content}
|
||||||
|
openGraph={{
|
||||||
|
basic: {
|
||||||
|
title: data.body?.title ? data.body.title : `Post #${data.id}`,
|
||||||
|
type: "article",
|
||||||
|
image: data.body?.thumbnail ? getAttachmentUrl(data.body.thumbnail) : getAttachmentUrl(attachments.find(a => a.mimetype.startsWith('image'))?.rid),
|
||||||
|
url: `https://solsynth.dev/posts/${data.id}`
|
||||||
|
},
|
||||||
|
article: {
|
||||||
|
publishedTime: new Date(data.created_at).toISOString(),
|
||||||
|
modifiedTime: new Date(data.updated_at).toISOString(),
|
||||||
|
authors: ["@"+data.publisher.name],
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
twitter={{
|
||||||
|
title: data.body?.title ? data.body.title : `Post #${data.id}`,
|
||||||
|
description: data.body?.content,
|
||||||
|
creator: "@"+data.publisher.name,
|
||||||
|
image: data.body?.thumbnail ? getAttachmentUrl(data.body.thumbnail) : getAttachmentUrl(attachments.find(a => a.mimetype.startsWith('image'))?.rid),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<Layout title={data.body?.title ? data.body.title : `Post #${data.id}`} trailingTitle='Solar Network'>
|
||||||
<div role="alert" class="alert shadow-lg px-12 m-0 rounded-none mb-5">
|
<div role="alert" class="alert shadow-lg px-12 m-0 rounded-none mb-5">
|
||||||
<Icon
|
<Icon
|
||||||
name="material-symbols:ungroup"
|
name="material-symbols:ungroup"
|
||||||
|
@ -45,7 +45,7 @@ async function parseContent(data: string, useBreaks: boolean = false) {
|
|||||||
}
|
}
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout title="Posts">
|
<Layout title="Posts" trailingTitle='Solar Network'>
|
||||||
<div role="alert" class="alert shadow-lg px-12 m-0 rounded-none mb-5">
|
<div role="alert" class="alert shadow-lg px-12 m-0 rounded-none mb-5">
|
||||||
<Icon
|
<Icon
|
||||||
name="material-symbols:ungroup"
|
name="material-symbols:ungroup"
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
export function getAttachmentUrl(identifier: string): string {
|
export function getAttachmentUrl(identifier?: string): string {
|
||||||
|
if (!identifier) return ''
|
||||||
if (identifier.startsWith('http')) {
|
if (identifier.startsWith('http')) {
|
||||||
return identifier
|
return identifier
|
||||||
}
|
}
|
||||||
@ -13,7 +14,9 @@ export async function fetchAttachmentMeta(
|
|||||||
|
|
||||||
const baseUrl = import.meta.env.PUBLIC_SOLAR_NETWORK_URL
|
const baseUrl = import.meta.env.PUBLIC_SOLAR_NETWORK_URL
|
||||||
const resp = await fetch(
|
const resp = await fetch(
|
||||||
`${baseUrl}/cgi/uc/attachments?take=${identifiers.length}&id=${identifiers.join(',')}`
|
`${baseUrl}/cgi/uc/attachments?take=${
|
||||||
|
identifiers.length
|
||||||
|
}&id=${identifiers.join(',')}`
|
||||||
)
|
)
|
||||||
if (resp.status !== 200) {
|
if (resp.status !== 200) {
|
||||||
throw new Error(`Failed to fetch attachment meta: ${await resp.text()}`)
|
throw new Error(`Failed to fetch attachment meta: ${await resp.text()}`)
|
||||||
|
Loading…
Reference in New Issue
Block a user