Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not add placeholder="blur" on .svg static images #832

Merged
merged 1 commit into from
Sep 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/large-lemons-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'nextra': patch
---

do not add `placeholder="blur"` on `.svg` static images
5 changes: 4 additions & 1 deletion examples/swr-site/pages/docs/advanced/future-image.en-US.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
![](../../../public/favicon/android-chrome-512x512.png)
![](/swr-logo.svg)

![](/favicon/android-chrome-512x512.png)

![](../../../public/favicon/android-chrome-512x512.png)

22 changes: 13 additions & 9 deletions examples/swr-site/theme.config.tsx
Original file line number Diff line number Diff line change
@@ -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 }) => (
<svg height={height} viewBox="0 0 291 69" fill="none">
const Logo = (props: ComponentProps<"svg">): ReactElement => (
<svg viewBox="0 0 291 69" fill="none" {...props}>
<path
d="M0 36.53c.07 17.6 14.4 32.01 32.01 32.01a32.05 32.05 0 0032.01-32V32a13.2 13.2 0 0123.4-8.31h20.7A32.07 32.07 0 0077.2 0a32.05 32.05 0 00-32 32.01v4.52A13.2 13.2 0 0132 49.71a13.2 13.2 0 01-13.18-13.18 3.77 3.77 0 00-3.77-3.77H3.76A3.77 3.77 0 000 36.53zM122.49 68.54a32.14 32.14 0 01-30.89-23.7h20.67a13.16 13.16 0 0023.4-8.3V32A32.05 32.05 0 01167.68 0c17.43 0 31.64 14 32 31.33l.1 5.2a13.2 13.2 0 0023.4 8.31h20.7a32.07 32.07 0 01-30.91 23.7c-17.61 0-31.94-14.42-32.01-32l-.1-4.7v-.2a13.2 13.2 0 00-13.18-12.81 13.2 13.2 0 00-13.18 13.18v4.52a32.05 32.05 0 01-32.01 32.01zM247.94 23.7a13.16 13.16 0 0123.4 8.31 3.77 3.77 0 003.77 3.77h11.3a3.77 3.77 0 003.76-3.77A32.05 32.05 0 00258.16 0a32.07 32.07 0 00-30.92 23.7h20.7z"
fill="currentColor"
Expand Down Expand Up @@ -180,7 +181,7 @@ const config: DocsThemeConfig = {
const { locale } = useRouter();
return (
<>
<Logo height={12} />
<Logo className="h-3" />
<span
className="ltr:ml-2 rtl:mr-2 font-extrabold hidden md:inline select-none"
title={"SWR: " + (TITLE[locale] || "")}
Expand All @@ -198,12 +199,15 @@ const config: DocsThemeConfig = {
},
sidebar: {
defaultMenuCollapsed: true,
titleComponent: ({ title }) => (
<div className="flex items-center gap-2">
<Logo height={6} />
{title}
</div>
),
titleComponent: ({ title, type }) =>
type === "separator" ? (
<div className="flex items-center gap-2">
<Logo className="h-1.5 shrink-0" />
{title}
</div>
) : (
<>{title}</>
Comment on lines +202 to +209
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixes
image

),
},
titleSuffix() {
const { locale } = useRouter();
Expand Down
6 changes: 3 additions & 3 deletions packages/nextra/src/mdx-plugins/static-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const getASTNodeImport = (name: string, from: string) => ({
data: {
estree: {
type: 'Program',
sourceType: 'module',
body: [
{
type: 'ImportDeclaration',
Expand All @@ -27,8 +28,7 @@ const getASTNodeImport = (name: string, from: string) => ({
raw: `"${from}"`
}
}
],
sourceType: 'module'
]
}
}
})
Expand Down Expand Up @@ -82,7 +82,7 @@ export const remarkStaticImage: Plugin<
name: 'alt',
value: node.alt
},
{
!url.endsWith('.svg') && {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without this, will get an error
image

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks!

type: 'mdxJsxAttribute',
name: 'placeholder',
value: 'blur'
Expand Down