Skip to content

Commit

Permalink
Added code-syntex-highlight in blog post
Browse files Browse the repository at this point in the history
  • Loading branch information
meghsohor committed Nov 26, 2020
1 parent d1ea25a commit 75be012
Show file tree
Hide file tree
Showing 17 changed files with 724 additions and 199 deletions.
7 changes: 7 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ module.exports = {
maxWidth: 800,
},
},
{
resolve: `gatsby-remark-highlight-code`,
options: {
terminal: "carbon",
theme: "zenburn",
},
},
],
},
},
Expand Down
81 changes: 81 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"version": "1.0.0",
"author": "Shuvo <[email protected]>",
"dependencies": {
"@deckdeckgo/highlight-code": "^2.2.1",
"bootstrap": "^4.5.3",
"disqus-react": "^1.0.10",
"font-awesome": "^4.7.0",
Expand All @@ -16,6 +17,7 @@
"gatsby-plugin-offline": "^3.3.3",
"gatsby-plugin-react-helmet": "^3.3.14",
"gatsby-plugin-sharp": "^2.7.1",
"gatsby-remark-highlight-code": "^2.1.0",
"gatsby-remark-images": "^3.5.1",
"gatsby-source-filesystem": "^2.4.2",
"gatsby-transformer-remark": "^2.9.2",
Expand Down
15 changes: 7 additions & 8 deletions src/components/layout.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
/**
* Layout component that queries for data
* with Gatsby's useStaticQuery component
*
* See: https://www.gatsbyjs.com/docs/use-static-query/
*/

import React from "react"
import React, { useEffect } from "react"
import PropTypes from "prop-types"
import { useStaticQuery, graphql } from "gatsby"
import { Row, Col } from 'reactstrap'
import { defineCustomElements as deckDeckGoHighlightElement } from "@deckdeckgo/highlight-code/dist/loader"

import '../styles/main.css'

Expand All @@ -17,6 +11,11 @@ import Footer from "./footer"
import Sidebar from "./sidebar"

const Layout = ({ children, pageTitle, postAuthor, hideSidebar }) => {
useEffect( () => {

}, [])
deckDeckGoHighlightElement()

const data = useStaticQuery(graphql`
query SiteTitleQuery {
site {
Expand Down
88 changes: 45 additions & 43 deletions src/components/post.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,52 @@
import React from 'react'
import { Link } from 'gatsby'
import { Card, CardBody, CardText, CardTitle, CardSubtitle } from 'reactstrap'
import Img from 'gatsby-image'
import { slugify } from '../utils/utilityFunctions'
import React from "react"
import { Link } from "gatsby"
import { Card, CardBody, CardText, CardTitle, CardSubtitle } from "reactstrap"
import Img from "gatsby-image"

const Post = (props) => {
const { title, path, date, body, image, tags } = props.post;

return (
<Card
className={`${props.noMargin ? "" : "mb-5"} ${
props.columnView ? "blog-card" : ""
}`}
>
<Link to={path}>
<Img className="card-img-top" fluid={image} />
</Link>
<CardBody>
<CardTitle tag="h5">
<Link to={path}>{title}</Link>
</CardTitle>
<CardSubtitle className="text-muted">{date}</CardSubtitle>
<hr />
<CardText>{body}</CardText>
import { slugify } from "../utils/utilityFunctions"

<div className="d-flex align-items-center mt-auto flex-wrap">
<ul className="post-tags">
{tags.map((tag, i) => (
<li key={i}>
<Link
className="badge badge-default p-2 px-2 tag"
to={`/tag/${slugify(tag)}`}
>
{tag}
</Link>
</li>
))}
</ul>
const Post = props => {
const { title, path, date, body, image, tags } = props.post

<Link to={path} className="btn btn-outline-primary ml-auto">
Read Post
</Link>
</div>
</CardBody>
</Card>
)
return (
<Card
className={`${props.noMargin ? "" : "mb-5"} ${
props.columnView ? "blog-card" : ""
}`}
>
<Link to={path}>
<Img className="card-img-top" fluid={image} />
</Link>
<CardBody>
<CardTitle tag="h5">
<Link to={path}>{title}</Link>
</CardTitle>
<CardSubtitle className="text-muted">{date}</CardSubtitle>
<hr />
<CardText>{body}</CardText>

<div className="d-flex align-items-center mt-auto flex-wrap">
<ul className="post-tags">
{tags.map((tag, i) => (
<li key={i}>
<Link
className="badge badge-default p-2 px-2 tag"
to={`/tag/${slugify(tag)}`}
>
{tag}
</Link>
</li>
))}
</ul>

<Link to={path} className="btn btn-outline-primary ml-auto">
Read Post
</Link>
</div>
</CardBody>
</Card>
)
}

export default Post
Loading

0 comments on commit 75be012

Please sign in to comment.