tea3 / hexo-generator-amp

AMP ⚡ HTML (Accelerated Mobile Pages) generator for Hexo.
MIT License
127 stars 28 forks source link

How to designate common title image? #45

Closed sanori closed 6 years ago

sanori commented 6 years ago

In https://github.com/tea3/hexo-generator-amp/wiki/More-Settings#front-matter-option you said that someone can designate the image of BlogPosting by setting ampSettings.titleImage.path. the path seems to be relative to the resource directory of each post.

If I want to designate common images, such as different by posting categories, not each post, how can I point the image? Is the only way to copy same image to same post resource directory?

tea3 commented 6 years ago

@sanori Thank you for using this plugin.

If you want to designate common images, you shouldn't set the frontmatter option. To use common images , please set the substituteTitleImage option in _config.yml. https://github.com/tea3/hexo-generator-amp/wiki/More-Settings#substitutetitleimage

If there is no image url in the article, the image specified by substituteTitleImage is specified as the image of BlogPosting. for the detail , please see the following url or the following sample code. https://github.com/tea3/hexo-generator-amp/wiki/More-Settings#options

# _config.yml
#  hexo-generator-amp :: Advanced Settings of hexo-amp-generator
generator_amp:
  substituteTitleImage: 
    path:   sample/sample-substituteTitleImage.png    # Can also specify external URL
    width:  1024   # width >= 696px
    height: 800

However, if there is an image in the article, that image will take precedence. The best way is to specify an external URL (e.g. https://hoge.com/sample.jpg ) in ampSettings.titleImage.path in frontmatter for each posts.