mirror of
https://gitee.com/docsifyjs/docsify.git
synced 2024-12-02 12:10:04 +08:00
Merge pull request #991 from anikethsaha/develop
chore: removed the escaping of the name of sidebar
This commit is contained in:
commit
d60fb7da7b
@ -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>`
|
||||
|
@ -57,18 +57,3 @@ export function isFn(obj) {
|
||||
return typeof obj === 'function'
|
||||
}
|
||||
|
||||
/**
|
||||
* escape String
|
||||
*/
|
||||
export function escapeString(string) {
|
||||
const entityMap = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
'\'': ''',
|
||||
'/': '/'
|
||||
}
|
||||
|
||||
return String(string).replace(/[&<>"'/]/g, s => entityMap[s])
|
||||
}
|
Loading…
Reference in New Issue
Block a user