mirror of
https://github.com/sergeyyarkov/yarkov.tech.git
synced 2026-10-11 10:29:21 +03:00
optimize images
This commit is contained in:
parent
55f7ae0cba
commit
0ab2e7a3cf
@ -9,7 +9,7 @@ import { escape } from "html-escaper";
|
|||||||
import solid from "@astrojs/solid-js";
|
import solid from "@astrojs/solid-js";
|
||||||
import mdx from "@astrojs/mdx";
|
import mdx from "@astrojs/mdx";
|
||||||
import sitemap from "@astrojs/sitemap";
|
import sitemap from "@astrojs/sitemap";
|
||||||
// import image from "@astrojs/image";
|
import image from "@astrojs/image";
|
||||||
import compress from "astro-compress";
|
import compress from "astro-compress";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,7 +44,7 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
// image(),
|
image(),
|
||||||
compress(),
|
compress(),
|
||||||
mdx({
|
mdx({
|
||||||
remarkPlugins: [remarkGfm, remarkSmartypants],
|
remarkPlugins: [remarkGfm, remarkSmartypants],
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 59 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 31 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 31 KiB |
@ -1,6 +1,5 @@
|
|||||||
---
|
---
|
||||||
// import { Image } from "@astrojs/image/components";
|
import { Image, Picture } from "@astrojs/image/components";
|
||||||
// import * as utils from "@utils/string";
|
|
||||||
import { createDateFormatter } from "@root/utils";
|
import { createDateFormatter } from "@root/utils";
|
||||||
import ArticleComments from "@components/ArticleComments";
|
import ArticleComments from "@components/ArticleComments";
|
||||||
import "./ArticlePost.scss";
|
import "./ArticlePost.scss";
|
||||||
@ -39,13 +38,15 @@ const { title, coverImage, tags, author, published_at } = data;
|
|||||||
coverImage && (
|
coverImage && (
|
||||||
<div>
|
<div>
|
||||||
<figure>
|
<figure>
|
||||||
{coverImage && <img itemprop="image" src={coverImage} width="700" height="400" alt={title} />}
|
<Picture
|
||||||
{/* Render remote or local image */}
|
itemprop="image"
|
||||||
{/* utils.isURL(coverImage) ? (
|
src={coverImage}
|
||||||
<Image itemprop="image" src={coverImage} width={700} height={400} aspectRatio={"16:9"} format={"webp"} alt={data.title} />
|
sizes="(max-width: 500px) 500px, 700px"
|
||||||
) : (
|
widths={[500, 700]}
|
||||||
<Image itemprop="image" src={cover.default.src} width={700} height={400} aspectRatio={"16:9"} format={"webp"} alt={data.title} />
|
formats={["webp"]}
|
||||||
)*/}
|
aspectRatio={"16:9"}
|
||||||
|
alt={title}
|
||||||
|
/>
|
||||||
</figure>
|
</figure>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import BaseLayout from "@components/BaseLayout";
|
|||||||
import ArticleContent from "@components/ArticleContent";
|
import ArticleContent from "@components/ArticleContent";
|
||||||
import ArticlePost from "@components/ArticlePost";
|
import ArticlePost from "@components/ArticlePost";
|
||||||
import { SITE_METADATA } from "@root/config";
|
import { SITE_METADATA } from "@root/config";
|
||||||
|
import { isURL } from '@utils/string'
|
||||||
import "@styles/global.scss";
|
import "@styles/global.scss";
|
||||||
|
|
||||||
export interface Props extends BaseHeadProps {
|
export interface Props extends BaseHeadProps {
|
||||||
@ -27,7 +28,7 @@ const { lang = "ru", content, canonicalUrl } = Astro.props as Props;
|
|||||||
<meta property="og:type" content="article" />
|
<meta property="og:type" content="article" />
|
||||||
<meta property="og:url" content={canonicalUrl} />
|
<meta property="og:url" content={canonicalUrl} />
|
||||||
{content.coverImage && (
|
{content.coverImage && (
|
||||||
<meta property="og:image" content={`${Astro.url.origin}${content.coverImage}`} />
|
<meta property="og:image" content={isURL(content.coverImage) ? content.coverImage : `${Astro.url.origin}${content.coverImage}`} />
|
||||||
<meta property="og:image:width" content="700" />
|
<meta property="og:image:width" content="700" />
|
||||||
<meta property="og:image:height" content="400" />
|
<meta property="og:image:height" content="400" />
|
||||||
<meta property="og:image:type" content={`${mime.lookup(extname(content.coverImage))}`} />
|
<meta property="og:image:type" content={`${mime.lookup(extname(content.coverImage))}`} />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user