This repository has been archived by the owner on Jul 12, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ setup remark and render the readme as the home page
setup remark and render the readme as the home page ✨ New feature
- Loading branch information
1 parent
1152e09
commit 56e18ad
Showing
6 changed files
with
602 additions
and
33 deletions.
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
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
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
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
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,29 +1,44 @@ | ||
import { GetStaticProps } from 'next'; | ||
import { Stack, Typography } from '@mui/joy'; | ||
import Link from 'next/link'; | ||
import { useTranslation } from 'next-i18next'; | ||
import { Stack } from '@mui/joy'; | ||
import { withTranslations } from '@/util/i18n/withTranslations'; | ||
import { join } from 'path'; | ||
import { readFileSync } from 'fs'; | ||
import { remark } from 'remark'; | ||
import html from 'remark-html'; | ||
|
||
const Home = () => { | ||
const { t } = useTranslation(); | ||
export interface HomePageProps { | ||
contentHtml: string; | ||
} | ||
|
||
const HomePage = (props: HomePageProps) => { | ||
return ( | ||
<Stack spacing={1}> | ||
<Typography level="h5">{t(`helloThere`)}</Typography> | ||
<Typography level="body2"> | ||
<Link href="https://github.com/TimMikeladze/next-apollo-joy-starter"> | ||
{t(`learnMore`, { | ||
url: t(`learnMoreUrl`), | ||
})} | ||
</Link> | ||
</Typography> | ||
<div dangerouslySetInnerHTML={{ __html: props.contentHtml }} /> | ||
</Stack> | ||
); | ||
}; | ||
|
||
export default Home; | ||
export default HomePage; | ||
|
||
export const getStaticProps: GetStaticProps = withTranslations(async () => { | ||
const fullPath = join(`.`, `README.md`); | ||
let fileContents = readFileSync(fullPath, `utf8`); | ||
|
||
fileContents = fileContents | ||
.split( | ||
` | ||
`, | ||
) | ||
.splice(2, fileContents.length) | ||
.join(`\n`); | ||
|
||
const processedContent = await remark().use(html).process(fileContents); | ||
|
||
const contentHtml = processedContent.toString(); | ||
|
||
export const getStaticProps: GetStaticProps = withTranslations(() => { | ||
return { | ||
props: {}, | ||
props: { | ||
contentHtml, | ||
}, | ||
}; | ||
}); |
Oops, something went wrong.
56e18ad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
next-apollo-joy-starter – ./
next-apollo-joy-starter-git-master-timmikeladze.vercel.app
next-apollo-joy-starter.vercel.app
next-apollo-joy-starter-timmikeladze.vercel.app