Skip to content

Commit

Permalink
adding chat and comment features
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorflg committed Apr 21, 2019
1 parent cffa9a1 commit 165df9f
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 12 deletions.
53 changes: 53 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"dependencies": {
"@hot-loader/react-dom": "^16.8.4",
"bulma": "^0.7.0",
"disqus-react": "^1.0.5",
"gatsby": "^2.1.34",
"gatsby-image": "^2.0.23",
"gatsby-plugin-google-fonts": "0.0.4",
Expand Down
28 changes: 28 additions & 0 deletions src/components/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,34 @@ const TemplateWrapper = ({ children }) => {
<meta property="og:title" content={title} />
<meta property="og:url" content="/" />
<meta property="og:image" content="/img/og-image.jpg" />
<script>
{
`"use strict";
!function() {
var t = window.driftt = window.drift = window.driftt || [];
if (!t.init) {
if (t.invoked) return void (window.console && console.error && console.error("Drift snippet included twice."));
t.invoked = !0, t.methods = [ "identify", "config", "track", "reset", "debug", "show", "ping", "page", "hide", "off", "on" ],
t.factory = function(e) {
return function() {
var n = Array.prototype.slice.call(arguments);
return n.unshift(e), t.push(n), t;
};
}, t.methods.forEach(function(e) {
t[e] = t.factory(e);
}), t.load = function(t) {
var e = 3e5, n = Math.ceil(new Date() / e) * e, o = document.createElement("script");
o.type = "text/javascript", o.async = !0, o.crossorigin = "anonymous", o.src = "https://js.driftt.com/include/" + n + "/" + t + ".js";
var i = document.getElementsByTagName("script")[0];
i.parentNode.insertBefore(o, i);
};
}
}();
drift.SNIPPET_VERSION = '0.3.1';
drift.load('3f9r43r5hkes');`
}
</script>
</Helmet>
<Navbar />
<div>{children}</div>
Expand Down
39 changes: 39 additions & 0 deletions src/html.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from "react"
import PropTypes from "prop-types"

export default function HTML(props) {
return (
<html {...props.htmlAttributes}>
<head>
<meta charSet="utf-8" />
<meta httpEquiv="x-ua-compatible" content="ie=edge" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
{props.headComponents}
</head>
<body {...props.bodyAttributes}>
{props.preBodyComponents}
<noscript key="noscript" id="gatsby-noscript">
This app works best with JavaScript enabled.
</noscript>
<div
key={`body`}
id="___gatsby"
dangerouslySetInnerHTML={{ __html: props.body }}
/>
{props.postBodyComponents}
</body>
</html>
)
}

HTML.propTypes = {
htmlAttributes: PropTypes.object,
headComponents: PropTypes.array,
bodyAttributes: PropTypes.object,
preBodyComponents: PropTypes.array,
body: PropTypes.string,
postBodyComponents: PropTypes.array,
}
26 changes: 14 additions & 12 deletions src/templates/blog-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import Helmet from 'react-helmet'
import { graphql, Link } from 'gatsby'
import Layout from '../components/Layout'
import Content, { HTMLContent } from '../components/Content'
import { DiscussionEmbed } from "disqus-react";

export const BlogPostTemplate = ({
id,
content,
contentComponent,
description,
Expand All @@ -16,6 +18,16 @@ export const BlogPostTemplate = ({
}) => {
const PostContent = contentComponent || Content

console.log(PostContent)

// const post = this.props.data.markdownRemark;
// const { previous, next } = this.props.pathContext;
const disqusShortname = "vitorflg";
const disqusConfig = {
identifier: id,
title: title,
};

return (
<section className="section">
{helmet || ''}
Expand All @@ -27,18 +39,7 @@ export const BlogPostTemplate = ({
</h1>
<p>{description}</p>
<PostContent content={content} />
{tags && tags.length ? (
<div style={{ marginTop: `4rem` }}>
<h4>Tags</h4>
<ul className="taglist">
{tags.map(tag => (
<li key={tag + `tag`}>
<Link to={`/tags/${kebabCase(tag)}/`}>{tag}</Link>
</li>
))}
</ul>
</div>
) : null}
<DiscussionEmbed shortname={disqusShortname} config={disqusConfig} />
</div>
</div>
</div>
Expand All @@ -60,6 +61,7 @@ const BlogPost = ({ data }) => {
return (
<Layout>
<BlogPostTemplate
id={post.id}
content={post.html}
contentComponent={HTMLContent}
description={post.frontmatter.description}
Expand Down

0 comments on commit 165df9f

Please sign in to comment.