feat: add logo option, #264 (#541)

This commit is contained in:
cinwell.li 2018-06-19 08:19:21 +08:00 committed by GitHub
commit ee72dd05e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 192 additions and 142 deletions

View file

@ -204,7 +204,7 @@ export class Compiler {
title = str
if (
!/:|(\/{2})/.test(href) &&
!isAbsolutePath(href) &&
!_self._matchNotCompileLink(href) &&
!config.ignore
) {

View file

@ -32,7 +32,9 @@ function formatUpdated(html, updated, fn) {
updated =
typeof fn === 'function' ?
fn(updated) :
typeof fn === 'string' ? tinydate(fn)(new Date(updated)) : updated
typeof fn === 'string' ?
tinydate(fn)(new Date(updated)) :
updated
return html.replace(/{docsify-updated}/g, updated)
}
@ -229,6 +231,10 @@ export function initRender(vm) {
html += tpl.cover()
}
if (config.logo) {
config.logo = getPath(vm.router.getBasePath(), config.logo)
}
html += tpl.main(config)
// Render main app
vm._renderTo(el, html, true)

View file

@ -36,7 +36,11 @@ export function main(config) {
'</button>' +
'<aside class="sidebar">' +
(config.name ?
`<h1><a class="app-name-link" data-nosearch>${config.name}</a></h1>` :
`<h1><a class="app-name-link" data-nosearch>${
config.logo ?
`<img alt=${config.name} src=${config.logo}>` :
config.name
}</a></h1>` :
'') +
'<div class="sidebar-nav"><!--sidebar--></div>' +
'</aside>'