Skip to content

a hexo plugin let you can define image url in post md and refer it in templates

License

Notifications You must be signed in to change notification settings

roybein/hexo-url-image

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Hexo Url Image

A Hexo plugin to allow adding url_image in front-matter, then you can refer post.url_image in your templates;

For example:

CoolPost.md

---
title: Cool post
url_image: my_img.png
---
What a cool blog I have!

By setting url_image, you specify a post's url image in its front matter.

The absolute path to my_img.png will be available through post.url_image in your templates.

For example:

article.ejs

...
<% if (post.url_image){ %>
    <img src="<%- post.url_image %>">
<% } %>
...

Installation

npm install --save hexo-url-image

Usage

This plugin will make automatically make post.url_image available in your templates when you run hexo server or hexo generate.

If you are using hexo-generator-json-content, it will automatically add the url_image property to content.json when you run hexo generate and when you exit hexo server.

Configuration

URL

For this plugin to work correctly, you must set image_server_url to your URL in _config.yml or use complete URLs. If you use a image cloud server with url //some.bkt.clouddn.com/, set it like this:

_config.yml

...
# URL
image_server_url: http://some.bkt.clouddn.com/
...

If you use images from multiple sources, set image_server_url to be blank, and use the complete URL for each image.

This plugin plays nicely with hexo-generator-json-content, and will output the absolute path of url_image to content.json if url_image has been set to true in the jsonContent configuration part of _config.yml like so:

...
jsonContent: {
	...
    posts: {
    	...
        url_image: true
        thumbnail: true # if you want thumbnail to be added as well
    }
}

About

a hexo plugin let you can define image url in post md and refer it in templates

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published