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

Image component added #253

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
21 changes: 21 additions & 0 deletions components/CustomImage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Image from 'next/image';

export default function CustomImage({
src,
alt = 'alt',
width = 800,
height = 350,
...props
}) {
return (
<Image
src={src}
alt={alt}
width={width}
height={height}
// Set quality as per need
quality={70}
{...props}
/>
);
}
6 changes: 1 addition & 5 deletions components/CustomLink.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import Link from 'next/link';

export default function CustomLink({ as, href, ...otherProps }) {
return <>
<Link as={as} href={href} {...otherProps}>

</Link>
</>;
return <Link as={as} href={href} {...otherProps} />;
}
2 changes: 1 addition & 1 deletion pages/_document.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class MyDocument extends Document {
<Html lang="en" className="theme-compiled">
<Head />
<body
className={`antialiased text-lg bg-white dark:bg-gray-900 dark:text-white leading-base`}
className={`antialiased text-lg bg-white dark:bg-gray-900 dark:text-white leading-base font-secondary`}
>
<Main />
<NextScript />
Expand Down
22 changes: 11 additions & 11 deletions pages/posts/[slug].js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Footer from '../../components/Footer';
import Header from '../../components/Header';
import Layout, { GradientBackground } from '../../components/Layout';
import SEO from '../../components/SEO';
import CustomImage from '../../components/CustomImage';

// Custom components/renderers to pass to MDX.
// Since the MDX files aren't loaded by webpack, they have no knowledge of how
Expand All @@ -26,6 +27,7 @@ const components = {
// useful for conditionally loading components for certain routes.
// See the notes in README.md for more details.
Head,
img: CustomImage,
};

export default function PostPage({
Expand All @@ -52,40 +54,38 @@ export default function PostPage({
)}
</header>
<main>
<article className="prose dark:prose-dark">
<article className="prose dark:prose-invert prose-img:rounded-md prose-headings:font-primary !max-w-full">
<MDXRemote {...source} components={components} />
</article>
</main>
<div className="grid mt-12 md:grid-cols-2 lg:-mx-24">
{prevPost && (
(<Link
<Link
href={`/posts/${prevPost.slug}`}
className="flex flex-col px-10 py-8 text-center transition bg-white border border-gray-800 md:text-right first:rounded-t-lg md:first:rounded-tr-none md:first:rounded-l-lg last:rounded-r-lg first last:rounded-b-lg backdrop-blur-lg dark:bg-black dark:bg-opacity-30 bg-opacity-10 hover:bg-opacity-20 dark:hover:bg-opacity-50 dark:border-white border-opacity-10 dark:border-opacity-10 last:border-t md:border-r-0 md:last:border-r md:last:rounded-r-none">

className="flex flex-col px-10 py-8 text-center transition bg-white border border-gray-800 md:text-right first:rounded-t-lg md:first:rounded-tr-none md:first:rounded-l-lg last:rounded-r-lg first last:rounded-b-lg backdrop-blur-lg dark:bg-black dark:bg-opacity-30 bg-opacity-10 hover:bg-opacity-20 dark:hover:bg-opacity-50 dark:border-white border-opacity-10 dark:border-opacity-10 last:border-t md:border-r-0 md:last:border-r md:last:rounded-r-none"
>
<p className="mb-4 text-gray-500 uppercase dark:text-white dark:opacity-60">
Previous
</p>
<h4 className="mb-6 text-2xl text-gray-700 dark:text-white">
{prevPost.title}
</h4>
<ArrowIcon className="mx-auto mt-auto transform rotate-180 md:mr-0" />

</Link>)
</Link>
)}
{nextPost && (
(<Link
<Link
href={`/posts/${nextPost.slug}`}
className="flex flex-col px-10 py-8 text-center transition bg-white border border-t-0 border-b-0 border-gray-800 md:text-left md:first:rounded-t-lg last:rounded-b-lg first:rounded-l-lg md:last:rounded-bl-none md:last:rounded-r-lg backdrop-blur-lg dark:bg-black dark:bg-opacity-30 bg-opacity-10 hover:bg-opacity-20 dark:hover:bg-opacity-50 dark:border-white border-opacity-10 dark:border-opacity-10 first:border-t first:rounded-t-lg md:border-t last:border-b">

className="flex flex-col px-10 py-8 text-center transition bg-white border border-t-0 border-b-0 border-gray-800 md:text-left md:first:rounded-t-lg last:rounded-b-lg first:rounded-l-lg md:last:rounded-bl-none md:last:rounded-r-lg backdrop-blur-lg dark:bg-black dark:bg-opacity-30 bg-opacity-10 hover:bg-opacity-20 dark:hover:bg-opacity-50 dark:border-white border-opacity-10 dark:border-opacity-10 first:border-t first:rounded-t-lg md:border-t last:border-b"
>
<p className="mb-4 text-gray-500 uppercase dark:text-white dark:opacity-60">
Next
</p>
<h4 className="mb-6 text-2xl text-gray-700 dark:text-white">
{nextPost.title}
</h4>
<ArrowIcon className="mx-auto mt-auto md:ml-0" />

</Link>)
</Link>
)}
</div>
</article>
Expand Down
4 changes: 4 additions & 0 deletions posts/example-post.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ var foo = function (bar) {
console.log(foo(5));
```

Images

![example-img](/example-img.avif "a title")

## Tables

| Option | Description |
Expand Down
Binary file added public/example-img.avif
Binary file not shown.
15 changes: 1 addition & 14 deletions styles/globals.css
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@tailwind variants;

h1,
h2,
h3,
h4,
h5,
h6 {
font-family: var(--font-primary);
}

body {
font-family: var(--font-secondary);
}
@tailwind variants;