Inline remote and local asset files when generate site. Supports CSS and JS files.
To install hexo-filter-asset-inline
run:
npm install hexo-filter-asset-inline --save
Append __inline=true
to the URL or relative path of asset file. Make sure __inline=true
is at the end of path or URL.
Examples:
For local css with relative path.
<link rel="stylesheet" type="text/css" href="/css/a.css?__inline=true"><!--will be inlined-->
<link rel="stylesheet" type="text/css" href="/css/a.css"><!--will not inlined-->
<link rel="stylesheet" type="text/css" href="/css/a.css?__inline=false"><!--will not inlined-->
For remote css with URL.
<link rel="stylesheet" type="text/css" href="//cdn.bootcss.com/highlight.js/8.4/styles/github.min.css?__inline=true"><!--will be inlined-->
<link rel="stylesheet" type="text/css" href="//cdn.bootcss.com/highlight.js/8.4/styles/github.min.css"><!--will not inlined-->
<link rel="stylesheet" type="text/css" href="//cdn.bootcss.com/highlight.js/8.4/styles/github.min.css?__inline=false"><!--will not inlined-->
For local js with relative path.
<script type="text/javascript" src="/js/a.js?__inline=true"></script><!--will be inlined-->
<script type="text/javascript" src="/js/a.js"></script><!--will not inlined-->
<script type="text/javascript" src="/js/a.js?__inline=false"></script><!--will not inlined-->
For remote js with URL.
<script type="text/javascript" src="//cdn.bootcss.com/highlight.js/8.9.1/highlight.min.js?__inline=true"></script><!--will be inlined-->
<script type="text/javascript" src="//cdn.bootcss.com/highlight.js/8.9.1/highlight.min.js"></script><!--will not inlined-->
<script type="text/javascript" src="//cdn.bootcss.com/highlight.js/8.9.1/highlight.min.js?__inline=false"></script><!--will not inlined-->
- not support font-awesome css
- not support web font css