fix highlighting on posts and pages
This commit is contained in:
parent
7e838f31ec
commit
5a94ee35e6
3 changed files with 11 additions and 5 deletions
|
|
@ -6,7 +6,6 @@ import {
|
||||||
withRouter
|
withRouter
|
||||||
} from 'react-router-dom';
|
} from 'react-router-dom';
|
||||||
|
|
||||||
import hljs from 'highlight.js';
|
|
||||||
import 'highlight.js/styles/github-gist.css';
|
import 'highlight.js/styles/github-gist.css';
|
||||||
|
|
||||||
import { Container, Row, Column } from './skeleton';
|
import { Container, Row, Column } from './skeleton';
|
||||||
|
|
@ -67,10 +66,6 @@ class App extends Component {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
document.title = this.title;
|
document.title = this.title;
|
||||||
|
|
||||||
// Auto-highlight all <pre><code> blocks
|
|
||||||
hljs.initHighlightingOnLoad();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import hljs from 'highlight.js';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import Icon from 'react-fontawesome';
|
import Icon from 'react-fontawesome';
|
||||||
import Markdown from 'react-markdown';
|
import Markdown from 'react-markdown';
|
||||||
|
|
@ -34,6 +35,12 @@ class Article extends Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
document.querySelectorAll('pre code').forEach(elm => {
|
||||||
|
hljs.highlightBlock(elm);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
postLink() {
|
postLink() {
|
||||||
let date = new Date(this.props.article.date);
|
let date = new Date(this.props.article.date);
|
||||||
let year = date.getUTCFullYear();
|
let year = date.getUTCFullYear();
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import hljs from 'highlight.js';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import Markdown from 'react-markdown';
|
import Markdown from 'react-markdown';
|
||||||
import slugify from 'slugify';
|
import slugify from 'slugify';
|
||||||
|
|
@ -45,6 +46,9 @@ class Page extends Component {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.fetchPage();
|
this.fetchPage();
|
||||||
|
document.querySelectorAll('pre code').forEach(elm => {
|
||||||
|
hljs.highlightBlock(elm);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(props) {
|
componentWillReceiveProps(props) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue