Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问如何根据页面的类型或者页面上的标签在标签的处理过程中返回不同的值? #521

Closed
huberylee opened this issue Nov 18, 2015 · 1 comment
Labels

Comments

@huberylee
Copy link

作者,您好!先前在多图展示的问题 #395 上有跟您提过,我想在首页按照目前的效果展示,归档中只展示标题,但内容页按照原样显示。由于新版本的代码在代码高亮部分有问题 #459 ,所以我将作者实现的多图展示的代码扣到了旧有的版本上,目前只修改了归档中的显示效果 (归档),但不知道如何让内容页中原样显示,猜想是不是可以通过修改 group-pictures.js中的groupPicture函数来实现:

function groupPicture(args, content) {
  args = args[0].split('-');
  var group = parseInt(args[0]);
  var layout = parseInt(args[1]);

  content = hexo.render.renderSync({text: content, engine: 'markdown'});

  var pictures = content.match(/<img[\s\S]*?>/g);

  return '<div class="group-picture">' +
            templates.dispatch(pictures, group, layout) +
         '</div>';
}

修改为:

function groupPicture(args, content) {
  args = args[0].split('-');
  var group = parseInt(args[0]);
  var layout = parseInt(args[1]);

  content = hexo.render.renderSync({text: content, engine: 'markdown'});

  var pictures = content.match(/<img[\s\S]*?>/g);

  if(is_home())
    return '<div class="group-picture">' +
              templates.dispatch(pictures, group, layout) +
           '</div>';
  else
    return content;
}

但是,在扩展标签中似乎不能使用is_home(),不知道作者是否方便给出一点建议及指导,谢谢您!

@iissnan
Copy link
Owner

iissnan commented Nov 18, 2015

这个不好处理

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants