From d7e7f5b2b1437ce64dddcae2593240387ee76a45 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Sun, 11 Sep 2022 20:07:23 +0300 Subject: [PATCH] do not add `placeholder="blur"` on `.svg` static images (#832) --- .changeset/large-lemons-explode.md | 5 +++++ .../docs/advanced/future-image.en-US.mdx | 5 ++++- examples/swr-site/theme.config.tsx | 22 +++++++++++-------- .../nextra/src/mdx-plugins/static-image.ts | 6 ++--- 4 files changed, 25 insertions(+), 13 deletions(-) create mode 100644 .changeset/large-lemons-explode.md diff --git a/.changeset/large-lemons-explode.md b/.changeset/large-lemons-explode.md new file mode 100644 index 0000000000..ff5553ad06 --- /dev/null +++ b/.changeset/large-lemons-explode.md @@ -0,0 +1,5 @@ +--- +'nextra': patch +--- + +do not add `placeholder="blur"` on `.svg` static images diff --git a/examples/swr-site/pages/docs/advanced/future-image.en-US.mdx b/examples/swr-site/pages/docs/advanced/future-image.en-US.mdx index 0b209de411..98c5b1022c 100644 --- a/examples/swr-site/pages/docs/advanced/future-image.en-US.mdx +++ b/examples/swr-site/pages/docs/advanced/future-image.en-US.mdx @@ -1,3 +1,6 @@ -![](../../../public/favicon/android-chrome-512x512.png) +![](/swr-logo.svg) ![](/favicon/android-chrome-512x512.png) + +![](../../../public/favicon/android-chrome-512x512.png) + diff --git a/examples/swr-site/theme.config.tsx b/examples/swr-site/theme.config.tsx index 71e76585d3..ebc5a37d7a 100644 --- a/examples/swr-site/theme.config.tsx +++ b/examples/swr-site/theme.config.tsx @@ -1,9 +1,10 @@ /* eslint sort-keys: error */ import { useRouter } from "next/router"; +import { ComponentProps, ReactElement } from "react"; import { DocsThemeConfig, useConfig } from "nextra-theme-docs"; -const Logo = ({ height }) => ( - +const Logo = (props: ComponentProps<"svg">): ReactElement => ( + - + ( -
- - {title} -
- ), + titleComponent: ({ title, type }) => + type === "separator" ? ( +
+ + {title} +
+ ) : ( + <>{title} + ), }, titleSuffix() { const { locale } = useRouter(); diff --git a/packages/nextra/src/mdx-plugins/static-image.ts b/packages/nextra/src/mdx-plugins/static-image.ts index 8bd0a4463a..0e3d84123f 100644 --- a/packages/nextra/src/mdx-plugins/static-image.ts +++ b/packages/nextra/src/mdx-plugins/static-image.ts @@ -12,6 +12,7 @@ const getASTNodeImport = (name: string, from: string) => ({ data: { estree: { type: 'Program', + sourceType: 'module', body: [ { type: 'ImportDeclaration', @@ -27,8 +28,7 @@ const getASTNodeImport = (name: string, from: string) => ({ raw: `"${from}"` } } - ], - sourceType: 'module' + ] } } }) @@ -82,7 +82,7 @@ export const remarkStaticImage: Plugin< name: 'alt', value: node.alt }, - { + !url.endsWith('.svg') && { type: 'mdxJsxAttribute', name: 'placeholder', value: 'blur'