Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Commit

Permalink
馃悰 show getting started message if no README.md is present
Browse files Browse the repository at this point in the history
show getting started message if no README.md is present

馃悰 Bugfix
  • Loading branch information
TimMikeladze committed Dec 29, 2022
1 parent 7008d4b commit f684948
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { GetStaticProps } from 'next';
import { Stack } from '@mui/joy';
import { Stack, Box } from '@mui/joy';
import { withTranslations } from '@/util/i18n/withTranslations';
import { join } from 'path';
import { readFileSync } from 'fs';
import { existsSync, readFileSync } from 'fs';
import { remark } from 'remark';
import html from 'remark-html';

Expand All @@ -13,7 +13,7 @@ export interface HomePageProps {
const HomePage = (props: HomePageProps) => {
return (
<Stack spacing={1}>
<div dangerouslySetInnerHTML={{ __html: props.contentHtml }} />
<Box dangerouslySetInnerHTML={{ __html: props.contentHtml }} />
</Stack>
);
};
Expand All @@ -22,15 +22,19 @@ export default HomePage;

export const getStaticProps: GetStaticProps = withTranslations(async () => {
const fullPath = join(`.`, `README.md`);
let fileContents = readFileSync(fullPath, `utf8`);
let fileContents = existsSync(fullPath)
? readFileSync(fullPath, `utf8`)
: null;

fileContents = fileContents
.split(
`
? fileContents
.split(
`
`,
)
.splice(3, fileContents.length)
.join(`\n`);
)
.splice(3, fileContents.length)
.join(`\n`)
: `No README.md found in the root of the project. But that's okay! You probably just want begin coding your app. A great place to start would be by modifying the \`getStaticProps\` function in \`src/pages/index.tsx\` to remove this message and accompanying logic. Beyond that, good luck and happy coding!`;

const processedContent = await remark().use(html).process(fileContents);

Expand Down

0 comments on commit f684948

Please sign in to comment.