Skip to content

Commit

Permalink
modifying the way the site shows markdown and adding the bundle analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewevans0102 committed Apr 13, 2020
1 parent ff6b251 commit 058d5e3
Show file tree
Hide file tree
Showing 7 changed files with 837 additions and 105 deletions.
3 changes: 2 additions & 1 deletion _styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,14 @@ body {
justify-content: center;
align-items: center;
max-width: 800px;
margin: 20px;
}

&__image--container {
display: flex;
align-items: center;
max-width: 400px;
height: 400px;
height: 100%;

@media (max-width: $mobile-query) {
height: 100%;
Expand Down
8 changes: 4 additions & 4 deletions components/Post.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import ReactMarkdown from 'react-markdown';
import PostImage from './PostImage';

const Post = ({ post }) => {
Expand All @@ -7,9 +6,10 @@ const Post = ({ post }) => {
<div className="post__title">{post.title}</div>
<div className="post__date">{post.date}</div>
{post.coverImage && <PostImage coverImage={post.coverImage} />}
<article className="post__content">
<ReactMarkdown source={post.content} />
</article>
<article
className="post__content"
dangerouslySetInnerHTML={{ __html: post.content }}
/>
</section>
);
};
Expand Down
18 changes: 18 additions & 0 deletions lib/markdownToHtml.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import remark from 'remark';
import html from 'remark-html';

// this was originally copied from the React.js blog starter here
// https://github.com/zeit/next.js/blob/canary/examples/blog-starter/lib/markdownToHtml.js

// the "content" of this site's posts are just raw text for the most part, but using
// remark and remark-html here enables support if I want to use additional Markdown syntax

// if you get a terminal message like
// "mdast-util-to-hast: deprecation: `allowDangerousHTML` is nonstandard, use `allowDangerousHtml` instead"
// this is in the "mdast-util-to-hast project and is already being fixed by the PR here
// https://github.com/remarkjs/remark-html/pull/29

export default async function markdownToHtml(markdown) {
const result = await remark().use(html).process(markdown);
return result.toString();
}
4 changes: 4 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
module.exports = withBundleAnalyzer({});
Loading

1 comment on commit 058d5e3

@vercel
Copy link

@vercel vercel bot commented on 058d5e3 Apr 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.