声明文章是转载的
theme基于: ButterflyOut
在文章页头部指定参数:
1 2
|
copyright_author: aaa copyright_author_href: xxx
|
模板路径:themes/ButterflyOut/layout/includes/post/post-copyright.pug
我们可以在最下面添加转载的模板代码,下面是一个很简单的例子
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
// 转载文章的声明 if page.copyright === false - let author = page.copyright_author ? page.copyright_author : config.author - let authorHref = page.copyright_author_href ? page.copyright_author_href : `mailto:${config.email}` - let url = page.copyright_url ? page.copyright_url : page.permalink - let info = page.copyright_info ? page.copyright_info : _p('post.copyright.copyright_content', theme.post_copyright.license_url, theme.post_copyright.license, config.url, config.title) .post-copyright .post-copyright__author span.post-copyright-meta= "原文作者: " span.post-copyright-info a(href=authorHref)=author .post-copyright__type span.post-copyright-meta= "原文链接: " span.post-copyright-info a(href=url_for(url))= theme.post_copyright.decode ? decodeURI(url) : url
|
效果:
另外,如果还想在标题前面自动加上【转载】,还需要修改下面几个模板:
themes/ButterflyOut/layout/includes/head.pug:8
1 2 3 4 5
|
before: - else pageTitle = page.title || config.title || ''
after: - else pageTitle = (page.title && page.copyright === false ? ('【转载】' + page.title) : page.title) || config.title || ''
|
浏览器标签页上的效果:
themes/ButterflyOut/layout/includes/mixins/post-ui.pug:5
1 2 3 4 5
|
before: - var title = article.title || _p('no_title')
after: - var title = (article.title && article.copyright === false ? '【转载】' + article.title : article.title) || _p('no_title')
|
themes/ButterflyOut/layout/includes/header/post-info.pug:3
1 2 3 4 5
|
before: .posttitle= (page.title && page.copyright === false ? '【转载】' + page.title : page.title) || _p('no_title')
after: .posttitle= page.title || _p('no_title')
|
文章标题的效果:
当然还有其他地方会显示文章标题,这里就不再修改了