diff options
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/Head.astro | 37 | ||||
| -rw-r--r-- | src/components/Header.astro | 4 | ||||
| -rw-r--r-- | src/components/PostElement.astro | 2 | ||||
| -rw-r--r-- | src/components/Sections/LatestPosts.astro | 2 |
4 files changed, 34 insertions, 11 deletions
diff --git a/src/components/Head.astro b/src/components/Head.astro index 258162d..fbfba1c 100644 --- a/src/components/Head.astro +++ b/src/components/Head.astro @@ -1,33 +1,44 @@ --- import type { Thing } from "schema-dts"; +import { config } from "../config"; import JsonLd from "./JsonLd.astro"; type Props = { readonly description: string; + readonly lang: string; + readonly modifiedTime?: string; + readonly ogType?: "website" | "article"; readonly preview: string; + readonly publishedTime?: string; readonly robots?: string; readonly schema: Thing[]; readonly title: string; }; -const { description, preview, robots = "index, follow", schema, title } = Astro.props; +const { description, lang, modifiedTime, ogType = "website", preview, publishedTime, robots = "index, follow", schema, title } = Astro.props; const canonicalUrl = new URL(Astro.url.pathname, Astro.site); const previewUrl = new URL(preview, Astro.site); +const ogLocale = lang === "ru" ? "ru_RU" : "en_US"; --- <head> <!-- Meta Tags --> - <meta http-equiv="X-UA-Compatible" content="IE=edge" /> - <meta http-equiv="content-type" content="text/html; charset=utf-8" /> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="description" content={description} /> <meta name="robots" content={robots} /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> + <meta name="author" content={config.author.name} /> <link href="/feed.xml" rel="alternate" title="RSS" type="application/atom+xml" /> <link href="/sitemap-index.xml" rel="sitemap" /> <link href={canonicalUrl} rel="canonical" /> + <link href={config.author.url} rel="author" /> + + <!-- hreflang --> + <link rel="alternate" hreflang={lang} href={canonicalUrl} /> + <link rel="alternate" hreflang="x-default" href={canonicalUrl} /> <title>{title}</title> @@ -36,20 +47,32 @@ const previewUrl = new URL(preview, Astro.site); <link rel="icon" type="image/png" href="/favicon.png" /> <link rel="apple-touch-icon" href="/apple-touch-icon.png" /> <link rel="manifest" href="/manifest.json" /> - <meta name="theme-color" content="#ffffff" /> + <meta name="theme-color" content="#181818" /> <!-- Open Graph --> - <meta property="og:type" content="website" /> + <meta property="og:type" content={ogType} /> + <meta property="og:site_name" content={config.og.website} /> + <meta property="og:locale" content={ogLocale} /> <meta property="og:title" content={title} /> <meta property="og:description" content={description} /> - <meta property="og:image" content={previewUrl} /> <meta property="og:url" content={canonicalUrl} /> + <meta property="og:image" content={previewUrl} /> + <meta property="og:image:width" content={String(config.og.dimensions.width)} /> + <meta property="og:image:height" content={String(config.og.dimensions.height)} /> + <meta property="og:image:alt" content={title} /> + + {ogType === "article" && publishedTime && <meta property="article:published_time" content={publishedTime} />} + {ogType === "article" && modifiedTime && <meta property="article:modified_time" content={modifiedTime} />} + {ogType === "article" && <meta property="article:author" content={config.author.url} />} <!-- Twitter Cards --> <meta name="twitter:card" content="summary_large_image" /> + <meta name="twitter:site" content="@valyaha" /> + <meta name="twitter:creator" content="@valyaha" /> <meta name="twitter:title" content={title} /> <meta name="twitter:description" content={description} /> <meta name="twitter:image" content={previewUrl} /> + <meta name="twitter:image:alt" content={title} /> <JsonLd schema={schema} /> </head> diff --git a/src/components/Header.astro b/src/components/Header.astro index f9a0c57..3013520 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -10,7 +10,7 @@ <header> <nav aria-label="Navigation"> - <a href="/" lang="en" aria-label="Home">Home</a> - <a href="/blog/" lang="en" aria-label="Blog">Blog</a> + <a href="/" lang="en">Home</a> + <a href="/blog/" lang="en">Blog</a> </nav> </header> diff --git a/src/components/PostElement.astro b/src/components/PostElement.astro index 051a8ff..e201102 100644 --- a/src/components/PostElement.astro +++ b/src/components/PostElement.astro @@ -31,7 +31,7 @@ const datePublished = post.data.datePublished.toISOString(); <a href={`/blog/${post.id}`} lang={post.data.lang}>{post.data.title}</a> <div> <small> - <time datetime={datePublished} lang="en">{formattedDate}</time> + <time datetime={datePublished} lang={post.data.lang}>{formattedDate}</time> <span>•</span> <span>{remarkPluginFrontmatter.minutesRead}</span> </small> diff --git a/src/components/Sections/LatestPosts.astro b/src/components/Sections/LatestPosts.astro index 5c6afd9..daba4c8 100644 --- a/src/components/Sections/LatestPosts.astro +++ b/src/components/Sections/LatestPosts.astro @@ -32,7 +32,7 @@ const latestPosts = posts.slice(0, 5); </a> <small> - <time datetime={post.data.datePublished.toISOString()} lang="en"> + <time datetime={post.data.datePublished.toISOString()} lang={post.data.lang}> {dayjs(post.data.datePublished.toString()).format("MMMM DD, YYYY")} </time> </small> |
