diff --git a/astro.config.mjs b/astro.config.mjs index 6a35ce0..0844f88 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -7,9 +7,20 @@ import icon from 'astro-icon' import mdx from '@astrojs/mdx' +import sitemap from '@astrojs/sitemap' + // https://astro.build/config 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, i18n: { locales: ['en', 'zh-cn'], diff --git a/bun.lockb b/bun.lockb index 94d6aa6..a770448 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 7b5c030..66db0d3 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,13 @@ }, "dependencies": { "@astrojs/mdx": "^4.0.2", + "@astrojs/sitemap": "^3.2.1", "@astrojs/tailwind": "^5.1.3", "@iconify-json/material-symbols": "^1.2.10", "@iconify-json/simple-icons": "^1.2.16", "astro": "^5.0.5", "astro-icon": "^1.1.4", + "astro-seo": "^0.8.4", "marked": "^15.0.4", "sanitize-html": "^2.13.1", "tailwindcss": "^3.4.16" diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..ca569fb --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,4 @@ +User-agent: * +Allow: / + +Sitemap: https://solsynth.dev/sitemap-index.xml diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index b8c7f4b..06961a7 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -1,6 +1,4 @@ --- -export const prerender = false - import { Image } from 'astro:assets' import { version } from '../../package.json' @@ -10,9 +8,11 @@ import { getRelativeLocaleUrl } from 'astro:i18n' interface Props { title?: string + trailingTitle?: string } -const { title } = Astro.props +let { title, trailingTitle } = Astro.props +if(trailingTitle == null) trailingTitle = 'Solsynth LLC' const locale = Astro.currentLocale ?? 'en' --- @@ -23,7 +23,8 @@ const locale = Astro.currentLocale ?? 'en' - {title ? `${title} | Solsynth LLC` : 'Solsynth LLC'} + + {title ? `${title} | ${trailingTitle}` : trailingTitle} diff --git a/src/pages/posts/[...slug].astro b/src/pages/posts/[...slug].astro index b1d9778..dfe38e7 100644 --- a/src/pages/posts/[...slug].astro +++ b/src/pages/posts/[...slug].astro @@ -3,6 +3,7 @@ export const prerender = false import sanitizeHtml from 'sanitize-html' import { Icon } from 'astro-icon/components' +import {SEO} from 'astro-seo' import { marked } from 'marked' import Layout from '@/layouts/Layout.astro' @@ -28,7 +29,33 @@ const content = sanitizeHtml(rawContent) const attachments = await fetchAttachmentMeta(data.body.attachments) --- - + + 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), + }} + /> + + +