🐛 修復當博客root不是'/'時,引用本地圖片會顯示不出的bug close #211

This commit is contained in:
Jerry
2020-04-28 15:31:14 +08:00
parent 91d285391d
commit 250181c569
10 changed files with 31 additions and 16 deletions

View File

@@ -35,7 +35,15 @@ git clone -b dev https://github.com/jerryc127/hexo-theme-butterfly.git themes/Bu
## Documentation ## Documentation
Find in [hexo-theme-butterfly docs](https://docs.jerryc.me) and [JerryC](https://jerryc.me/posts/21cfbf15). it supports `zh-TW` Find in [hexo-theme-butterfly docs](https://docs.jerryc.me) and [JerryC](https://jerryc.me/posts/21cfbf15). it supports `zh-TW` and `zh-CN`
You can also join the Chat Group.
[ 💬 Join QQ Group [recommend]](https://jq.qq.com/?_wv=1027&k=5KI3Jqb)
[ 💬 Join Telegram Group](https://t.me/hexo_butterfly)
## Screenshots ## Screenshots

View File

@@ -36,7 +36,14 @@ theme: Butterfly
可查看[hexo-theme-butterfly docs](https://docs.jerryc.me) 和 [JerryC](https://jerryc.me/posts/21cfbf15) 可查看[hexo-theme-butterfly docs](https://docs.jerryc.me) 和 [JerryC](https://jerryc.me/posts/21cfbf15)
你也可以加入群組
[ 💬 QQ群 [推薦]](https://jq.qq.com/?_wv=1027&k=5KI3Jqb)
[ 💬Telegram群](https://t.me/hexo_butterfly)
## 截圖 ## 截圖
![image](https://user-images.githubusercontent.com/16351105/58887365-1272f780-8718-11e9-9329-3292c6ba20d4.png) ![image](https://user-images.githubusercontent.com/16351105/58887365-1272f780-8718-11e9-9329-3292c6ba20d4.png)
![image](https://user-images.githubusercontent.com/16351105/58887457-3cc4b500-8718-11e9-9417-2bdea603c92e.png) ![image](https://user-images.githubusercontent.com/16351105/58887457-3cc4b500-8718-11e9-9417-2bdea603c92e.png)

View File

@@ -1,5 +1,5 @@
- var top_img = theme.error_404.background || theme.default_top_img - var top_img = theme.error_404.background || theme.default_top_img
- var bg_img = `background-image: url(${top_img})` - var bg_img = `background-image: url(${url_for(top_img)})`
doctype html doctype html
html(lang=config.language data-theme=theme.display_mode) html(lang=config.language data-theme=theme.display_mode)

View File

@@ -7,11 +7,11 @@
.md-links .md-links
each item in i.link_list each item in i.link_list
.md-links-item .md-links-item
a(href=item.link title=item.name target="_blank") a(href=url_for(item.link) title=item.name target="_blank")
if theme.lazyload.enable if theme.lazyload.enable
img.lazyload(data-src=item.avatar onerror=`this.onerror=null;this.src='` + url_for(theme.lodding_bg.flink) + `'` alt=item.name ) img.lazyload(data-src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.lodding_bg.flink) + `'` alt=item.name )
else else
img(src=item.avatar onerror=`this.onerror=null;this.src='` + url_for(theme.lodding_bg.flink) + `'` alt=item.name ) img(src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.lodding_bg.flink) + `'` alt=item.name )
.md-links-title= item.name .md-links-title= item.name
.md-links-des= item.descr .md-links-des= item.descr
!= page.content != page.content

View File

@@ -19,7 +19,7 @@ if theme.douban
else if is_current('/games/', [strict]) else if is_current('/games/', [strict])
- var top_img = theme.douban.games_img || theme.default_top_img - var top_img = theme.douban.games_img || theme.default_top_img
- var bg_img = top_img && top_img !== true ? `background-image: url(${top_img})` : '' - var bg_img = top_img && top_img !== true ? `background-image: url(${url_for(top_img)})` : ''
- var site_title = is_archive() ? _p('page.archives') : page.title || page.tag || page.category || config.title - var site_title = is_archive() ? _p('page.archives') : page.title || page.tag || page.category || config.title
- var isHomeClass = is_home() ? 'full_page' : 'not-index-bg' - var isHomeClass = is_home() ? 'full_page' : 'not-index-bg'
- is_post() ? isHomeClass = 'post-bg' : isHomeClass - is_post() ? isHomeClass = 'post-bg' : isHomeClass

View File

@@ -11,7 +11,7 @@ mixin articleSort(posts)
if article.cover && theme.cover.archives_enable if article.cover && theme.cover.archives_enable
.article-sort-img .article-sort-img
a.article-sort-item__img(href=url_for(article.path)) a.article-sort-item__img(href=url_for(article.path))
img(src=`${article.cover}` alt=article.title || 'No Title' onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'`) img(src=url_for(article.cover) alt=article.title || 'No Title' onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'`)
.article-sort-post .article-sort-post
a.article-sort-item__post(href=url_for(article.path)) a.article-sort-item__post(href=url_for(article.path))
i.fa.fa-clock-o(aria-hidden="true") i.fa.fa-clock-o(aria-hidden="true")

View File

@@ -10,9 +10,9 @@ mixin postUI(posts)
.post_cover(class=leftOrRight) .post_cover(class=leftOrRight)
a(href=url_for(link) title=title) a(href=url_for(link) title=title)
if theme.lazyload.enable if theme.lazyload.enable
img.post_bg.lazyload(data-src=`${post_cover}` onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` alt=title) img.post_bg.lazyload(data-src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` alt=title)
else else
img.post_bg(src=`${post_cover}` onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` alt=title) img.post_bg(src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` alt=title)
.recent-post-info(class=no_cover) .recent-post-info(class=no_cover)
a.article-title(href=url_for(link) title=title)= title a.article-title(href=url_for(link) title=title)= title
.article-meta-wrap .article-meta-wrap

View File

@@ -18,9 +18,9 @@ else
- var pagination_cover = page.prev.cover === false ? page.prev.randomcover : page.prev.cover - var pagination_cover = page.prev.cover === false ? page.prev.randomcover : page.prev.cover
a(href=url_for(page.prev.path)) a(href=url_for(page.prev.path))
if theme.lazyload.enable if theme.lazyload.enable
img.prev_cover.lazyload(data-src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'` ) img.prev_cover.lazyload(data-src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.lodding_bg.post_page)}'` )
else else
img.prev_cover(src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'` ) img.prev_cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.lodding_bg.post_page)}'` )
.pagination-info .pagination-info
.label=_p('pagination.prev') .label=_p('pagination.prev')
.prev_info=page.prev.title .prev_info=page.prev.title
@@ -31,9 +31,9 @@ else
.next-post(class=hasPagePrev) .next-post(class=hasPagePrev)
a(href=url_for(page.next.path)) a(href=url_for(page.next.path))
if theme.lazyload.enable if theme.lazyload.enable
img.next_cover.lazyload(data-src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'`) img.next_cover.lazyload(data-src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.lodding_bg.post_page)}'`)
else else
img.next_cover(src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'`) img.next_cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.lodding_bg.post_page)}'`)
.pagination-info .pagination-info
.label=_p('pagination.next') .label=_p('pagination.next')
.next_info=page.next.title .next_info=page.next.title

View File

@@ -1,4 +1,4 @@
if (theme.sharejs && theme.sharejs.enable) if (theme.sharejs && theme.sharejs.enable)
.social-share(data-image= page.cover|| theme.avatar.img data-sites= theme.sharejs.sites) .social-share(data-image=url_for(page.cover|| theme.avatar.img) data-sites= theme.sharejs.sites)
link(rel="stylesheet" href=url_for(theme.CDN.sharejs_css)) link(rel="stylesheet" href=url_for(theme.CDN.sharejs_css))
script(src=url_for(theme.CDN.sharejs)) script(src=url_for(theme.CDN.sharejs))

View File

@@ -16,9 +16,9 @@
if post_cover && theme.cover.aside_enable if post_cover && theme.cover.aside_enable
.aside-post-cover .aside-post-cover
if theme.lazyload.enable if theme.lazyload.enable
img.aside-post-bg.lazyload(data-src=`${post_cover}` onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` title=title alt=title) img.aside-post-bg.lazyload(data-src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` title=title alt=title)
else else
img.aside-post-bg(src=`${post_cover}` onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` title=title alt=title) img.aside-post-bg(src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` title=title alt=title)
.aside-post-title(class=no_cover) .aside-post-title(class=no_cover)
.aside-post_title(href=url_for(link) title=article.title || _p('no_title'))= article.title || _p('no_title') .aside-post_title(href=url_for(link) title=article.title || _p('no_title'))= article.title || _p('no_title')
time.aside-post_meta.post-meta__date(title=_p('post.created') + ' ' + full_date(article.date)) #[=date(article.date, config.date_format)] time.aside-post_meta.post-meta__date(title=_p('post.created') + ' ' + full_date(article.date)) #[=date(article.date, config.date_format)]