Skip to content

Commit

Permalink
fix: update layouts import
Browse files Browse the repository at this point in the history
  • Loading branch information
hta218 committed Apr 2, 2024
1 parent 5656f4d commit 20558b5
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 10 deletions.
15 changes: 14 additions & 1 deletion components/MDXComponents.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
import { getMDXComponent } from 'mdx-bundler/client'
import { useMemo } from 'react'
import AuthorLayout from '~/layouts/AuthorLayout'
import PostLayout from '~/layouts/PostLayout'
import PostSimple from '~/layouts/PostSimple'
import ResumeLayout from '~/layouts/ResumeLayout'
import SnippetLayout from '~/layouts/SnippetLayout'
import type { MdxLayoutRendererProps } from '~/types/mdx'
import { Image } from './Image'
import { Link } from './Link'
import { Pre } from './Pre'

let Layouts = {
PostLayout: PostLayout,
PostSimple: PostSimple,
SnippetLayout: SnippetLayout,
AuthorLayout: AuthorLayout,
ResumeLayout: ResumeLayout,
}

let MDXComponents = {
Image,
a: Link,
pre: Pre,
wrapper: ({ components, layout, ...rest }) => {
let Layout = require(`../layouts/${layout}`).default
let Layout = Layouts[layout]
return <Layout {...rest} />
},
}
Expand Down
2 changes: 1 addition & 1 deletion layouts/AuthorLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useTranslation } from 'next-i18next'
import { PageSeo } from '~/components/SEO'
import type { AuthorLayoutProps } from '~/types/layout'

export function AuthorLayout({ children }: AuthorLayoutProps) {
function AuthorLayout({ children }: AuthorLayoutProps) {
let { t } = useTranslation('common')
let title = t('menu_about')
let description = t('about_description')
Expand Down
2 changes: 1 addition & 1 deletion layouts/ListLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PostsSearch } from '~/components/PostsSearch'
import type { ListLayoutProps } from '~/types/layout'
import { useTranslation } from 'next-i18next'

export function ListLayout(props: ListLayoutProps) {
function ListLayout(props: ListLayoutProps) {
let { posts, title, initialDisplayPosts = [], pagination } = props
let { t } = useTranslation('common')
let [searchValue, setSearchValue] = useState('')
Expand Down
2 changes: 1 addition & 1 deletion layouts/PostLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SocialShareButtons } from '~/components/SocialShareButtons'
import { siteMetadata } from '~/data/siteMetadata'
import type { PostLayoutProps } from '~/types/layout'

export function PostLayout(props: PostLayoutProps) {
function PostLayout(props: PostLayoutProps) {
let { frontMatter, authorDetails, page, children, commentConfig } = props
let { slug, fileName, date, title, tags, readingTime } = frontMatter
let postUrl = `${siteMetadata.siteUrl}/blog/${slug}`
Expand Down
2 changes: 1 addition & 1 deletion layouts/PostSimple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { SocialShareButtons } from '~/components/SocialShareButtons'
import { siteMetadata } from '~/data/siteMetadata'
import type { PostSimpleLayoutProps } from '~/types/layout'

export function PostSimple(props: PostSimpleLayoutProps) {
function PostSimple(props: PostSimpleLayoutProps) {
let { frontMatter, type, children, authorDetails, commentConfig } = props
let { date, title, slug, fileName, tags, readingTime } = frontMatter
let postUrl = `${siteMetadata.siteUrl}/${type}/${slug}`
Expand Down
2 changes: 1 addition & 1 deletion layouts/ResumeLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ScrollTopButton } from '~/components/ScrollTopButton'
import { ToC } from '~/components/ToC'
import { useTranslation } from 'next-i18next'

export function ResumeLayout({ children, toc }) {
function ResumeLayout({ children, toc }) {
let { t } = useTranslation('common')
let description = t('resume_description')

Expand Down
2 changes: 1 addition & 1 deletion layouts/SnippetLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SnippetCard } from '~/components/SnippetCard'
import type { SnippetLayoutProps } from '~/types/layout'

export function SnippetLayout({ snippets, description }: SnippetLayoutProps) {
function SnippetLayout({ snippets, description }: SnippetLayoutProps) {
return (
<div className="divide-y divide-gray-200 dark:divide-gray-700">
<header className="space-y-2 pb-8 pt-6 md:space-y-5">
Expand Down
2 changes: 1 addition & 1 deletion pages/blog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useTranslation } from 'next-i18next'
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import { PageSeo } from '~/components/SEO'
import { POSTS_PER_PAGE } from '~/constant'
import { ListLayout } from '~/layouts/ListLayout'
import ListLayout from '~/layouts/ListLayout'
import { getAllFilesFrontMatter } from '~/libs/mdx.server'
import type { BlogListProps } from '~/types/page'

Expand Down
2 changes: 1 addition & 1 deletion pages/snippets/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PageSeo } from 'components/SEO'
import { useTranslation } from 'next-i18next'
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import { SnippetLayout } from '~/layouts/SnippetLayout'
import SnippetLayout from '~/layouts/SnippetLayout'
import { getAllFilesFrontMatter } from '~/libs/mdx.server'
import type { SnippetFrontMatter } from '~/types/mdx'

Expand Down
2 changes: 1 addition & 1 deletion pages/tags/[tag].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useTranslation } from 'next-i18next'
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import path from 'path'
import { DEFAULT_LOCALE } from '~/constant'
import { ListLayout } from '~/layouts/ListLayout'
import ListLayout from '~/layouts/ListLayout'
import { getMetaData } from '~/libs/files.server'
import { getAllFilesFrontMatter } from '~/libs/mdx.server'
import { generateRss } from '~/libs/rss.server'
Expand Down

0 comments on commit 20558b5

Please sign in to comment.