Merge pull request #991 from anikethsaha/develop

chore: removed the escaping of the name of sidebar
This commit is contained in:
Anix 2019-12-28 22:12:16 +05:30 committed by GitHub
commit d60fb7da7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 27 deletions

View File

@ -1,5 +1,4 @@
import {isMobile} from '../util/env'
import {escapeString} from '../util/core'
import { isMobile } from '../util/env'
/**
* Render github corner
* @param {Object} data
@ -9,11 +8,13 @@ export function corner(data, cornerExternalLinkTarge) {
if (!data) {
return ''
}
if (!/\/\//.test(data)) {
data = 'https://github.com/' + data
}
data = data.replace(/^git\+/, '')
// double check
// Double check
cornerExternalLinkTarge = cornerExternalLinkTarge || '_blank'
return (
@ -31,8 +32,7 @@ export function corner(data, cornerExternalLinkTarge) {
* Render main content
*/
export function main(config) {
const name = config.name? escapeString(config.name):''
const name = config.name ? config.name : ''
const aside =
'<button class="sidebar-toggle" aria-label="Menu">' +
@ -41,13 +41,11 @@ export function main(config) {
'</div>' +
'</button>' +
'<aside class="sidebar">' +
(config.name ?
`<h1 class="app-name"><a class="app-name-link" data-nosearch>${
config.logo ?
`<img alt="${name}" src=${config.logo}>` :
name
}</a></h1>` :
'') +
(config.name
? `<h1 class="app-name"><a class="app-name-link" data-nosearch>${
config.logo ? `<img alt="${name}" src=${config.logo}>` : name
}</a></h1>`
: '') +
'<div class="sidebar-nav"><!--sidebar--></div>' +
'</aside>'
@ -88,6 +86,7 @@ export function tree(toc, tpl = '<ul class="app-sub-sidebar">{inner}</ul>') {
if (!toc || !toc.length) {
return ''
}
let innerHTML = ''
toc.forEach(node => {
innerHTML += `<li><a class="section-link" href="${node.slug}">${node.title}</a></li>`

View File

@ -57,18 +57,3 @@ export function isFn(obj) {
return typeof obj === 'function'
}
/**
* escape String
*/
export function escapeString(string) {
const entityMap = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
'\'': '&#39;',
'/': '&#x2F;'
}
return String(string).replace(/[&<>"'/]/g, s => entityMap[s])
}