mirror of
https://gitee.com/docsifyjs/docsify.git
synced 2024-11-30 02:58:37 +08:00
Merge pull request #974 from Koooooo-7/develop
[fix]#972 when 'logo' is set, 'name' is not set correctly inside the 'alt' as same as without 'logo' set.
This commit is contained in:
commit
1622578045
@ -1,4 +1,5 @@
|
||||
import {isMobile} from '../util/env'
|
||||
import {escapeString} from '../util/core'
|
||||
/**
|
||||
* Render github corner
|
||||
* @param {Object} data
|
||||
@ -30,6 +31,9 @@ export function corner(data, cornerExternalLinkTarge) {
|
||||
* Render main content
|
||||
*/
|
||||
export function main(config) {
|
||||
|
||||
const name = config.name? escapeString(config.name):''
|
||||
|
||||
const aside =
|
||||
'<button class="sidebar-toggle" aria-label="Menu">' +
|
||||
'<div class="sidebar-toggle-button">' +
|
||||
@ -39,9 +43,9 @@ export function main(config) {
|
||||
'<aside class="sidebar">' +
|
||||
(config.name ?
|
||||
`<h1 class="app-name"><a class="app-name-link" data-nosearch>${
|
||||
config.logo ?
|
||||
`<img alt=${config.name} src=${config.logo}>` :
|
||||
config.name
|
||||
config.logo ?
|
||||
`<img alt="${name}" src=${config.logo}>` :
|
||||
name
|
||||
}</a></h1>` :
|
||||
'') +
|
||||
'<div class="sidebar-nav"><!--sidebar--></div>' +
|
||||
|
@ -56,3 +56,19 @@ export function noop() {}
|
||||
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