mirror of
https://gitee.com/docsifyjs/docsify.git
synced 2024-12-02 12:10:04 +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 {isMobile} from '../util/env'
|
||||||
|
import {escapeString} from '../util/core'
|
||||||
/**
|
/**
|
||||||
* Render github corner
|
* Render github corner
|
||||||
* @param {Object} data
|
* @param {Object} data
|
||||||
@ -30,6 +31,9 @@ export function corner(data, cornerExternalLinkTarge) {
|
|||||||
* Render main content
|
* Render main content
|
||||||
*/
|
*/
|
||||||
export function main(config) {
|
export function main(config) {
|
||||||
|
|
||||||
|
const name = config.name? escapeString(config.name):''
|
||||||
|
|
||||||
const aside =
|
const aside =
|
||||||
'<button class="sidebar-toggle" aria-label="Menu">' +
|
'<button class="sidebar-toggle" aria-label="Menu">' +
|
||||||
'<div class="sidebar-toggle-button">' +
|
'<div class="sidebar-toggle-button">' +
|
||||||
@ -39,9 +43,9 @@ export function main(config) {
|
|||||||
'<aside class="sidebar">' +
|
'<aside class="sidebar">' +
|
||||||
(config.name ?
|
(config.name ?
|
||||||
`<h1 class="app-name"><a class="app-name-link" data-nosearch>${
|
`<h1 class="app-name"><a class="app-name-link" data-nosearch>${
|
||||||
config.logo ?
|
config.logo ?
|
||||||
`<img alt=${config.name} src=${config.logo}>` :
|
`<img alt="${name}" src=${config.logo}>` :
|
||||||
config.name
|
name
|
||||||
}</a></h1>` :
|
}</a></h1>` :
|
||||||
'') +
|
'') +
|
||||||
'<div class="sidebar-nav"><!--sidebar--></div>' +
|
'<div class="sidebar-nav"><!--sidebar--></div>' +
|
||||||
|
@ -56,3 +56,19 @@ export function noop() {}
|
|||||||
export function isFn(obj) {
|
export function isFn(obj) {
|
||||||
return typeof obj === 'function'
|
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