Add syntax highlighting to status JSON

This commit is contained in:
Christian Bundy 2019-08-13 16:30:43 -07:00
parent f03da5f4ec
commit 5f0e2d5cd1
No known key found for this signature in database
GPG Key ID: EB541AAEF4366237
1 changed files with 5 additions and 1 deletions

View File

@ -1,5 +1,6 @@
'use strict'
const template = require('./components/template')
const highlightJs = require('highlight.js')
const {
h1,
h2,
@ -31,6 +32,9 @@ module.exports = ({ status }) => {
const remotePeers = Object.keys(status.gossip || []).map(key => {
return li(key)
})
const raw = JSON.stringify(status, null, 2)
const rawHighlighted = highlightJs.highlight('json', raw).value
return template(
section({ class: 'message' },
@ -43,7 +47,7 @@ module.exports = ({ status }) => {
h3('Remote'),
ul(remotePeers),
h2('Raw'),
pre(JSON.stringify(status, null, 2))
pre({ innerHTML: rawHighlighted })
)
)
}