-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[components,mdx][s]: fix next seo images build error and add components
- add checks for next seo image in config - add custom anchor links component that supports next links - modify svg component to use react fragment replacing p tags
- Loading branch information
1 parent
d34e3cb
commit 3b198f7
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Link from 'next/link' | ||
|
||
const CustomLink = ({ href, ...rest }) => { | ||
const isInternalLink = href && href.startsWith('/') | ||
const isAnchorLink = href && href.startsWith('#') | ||
|
||
if (isInternalLink) { | ||
return ( | ||
<Link href={href}> | ||
<a {...rest} /> | ||
</Link> | ||
) | ||
} | ||
|
||
if (isAnchorLink) { | ||
return <a href={href} {...rest} /> | ||
} | ||
|
||
return <a target="_blank" rel="noopener noreferrer" href={href} {...rest} /> | ||
} | ||
|
||
export default CustomLink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
import { Fragment } from 'react' | ||
import { NextSeo } from 'next-seo' | ||
import Head from 'next/head' | ||
import CustomLink from './Link' | ||
import { Pre } from './Pre' | ||
import siteConfig from '../config/siteConfig' | ||
|
||
const components = { | ||
Head, | ||
a: CustomLink, | ||
pre: Pre, | ||
svg: props => <Fragment {...props} />, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
khalilcodes
Author
Contributor
|
||
GlobalTest: ({children}) => <h1 className="bg-red-300">{children}</h1>, | ||
wrapper: ({ layout, ...rest }) => { | ||
const Layout = require(`../layouts/${layout}`).default | ||
|
@@ -36,7 +40,7 @@ export default function MdxPage({ children, ...rest }) { | |
alt: frontMatter.title | ||
} | ||
] | ||
: siteConfig.nextSeo.openGraph.images, | ||
: siteConfig?.nextSeo?.openGraph?.images || [], | ||
}} | ||
/> | ||
<Component | ||
|
This is stripping svgs of their root tag , so it won't work. And btw, what's the purpose of it?