diff --git a/src/App.js b/src/App.js index 5892004..8d41b5c 100644 --- a/src/App.js +++ b/src/App.js @@ -6,7 +6,6 @@ import { withRouter } from 'react-router-dom'; -import hljs from 'highlight.js'; import 'highlight.js/styles/github-gist.css'; import { Container, Row, Column } from './skeleton'; @@ -67,10 +66,6 @@ class App extends Component { componentDidMount() { document.title = this.title; - - // Auto-highlight all
 blocks
-    hljs.initHighlightingOnLoad();
-
   }
 }
 
diff --git a/src/Article.js b/src/Article.js
index 1c20a6a..0531dc8 100644
--- a/src/Article.js
+++ b/src/Article.js
@@ -1,3 +1,4 @@
+import hljs from 'highlight.js';
 import React, { Component } from 'react';
 import Icon from 'react-fontawesome';
 import Markdown from 'react-markdown';
@@ -34,6 +35,12 @@ class Article extends Component {
     );
   }
 
+  componentDidMount() {
+    document.querySelectorAll('pre code').forEach(elm => {
+      hljs.highlightBlock(elm);
+    });
+  }
+
   postLink() {
     let date = new Date(this.props.article.date);
     let year = date.getUTCFullYear();
diff --git a/src/Page.js b/src/Page.js
index 796a472..4e01d29 100644
--- a/src/Page.js
+++ b/src/Page.js
@@ -1,3 +1,4 @@
+import hljs from 'highlight.js';
 import React, { Component } from 'react';
 import Markdown from 'react-markdown';
 import slugify from 'slugify';
@@ -45,6 +46,9 @@ class Page extends Component {
 
   componentDidMount() {
     this.fetchPage();
+    document.querySelectorAll('pre code').forEach(elm => {
+      hljs.highlightBlock(elm);
+    });
   }
 
   componentWillReceiveProps(props) {