Load Creative Commons badge via CDN (#267)
@ -61,13 +61,15 @@ custom_logo: #/uploads/custom-logo.jpg
|
||||
|
||||
# Creative Commons 4.0 International License.
|
||||
# See: https://creativecommons.org/about/cclicenses/
|
||||
# Available values of license: by | by-nc | by-nc-nd | by-nc-sa | by-nd | by-sa | zero
|
||||
# You can set a language value if you prefer a translated version of CC license, e.g. deed.zh
|
||||
# CC licenses are available in 39 languages, you can find the specific and correct abbreviation you need on https://creativecommons.org
|
||||
creative_commons:
|
||||
# Available values: by | by-nc | by-nc-nd | by-nc-sa | by-nd | by-sa | cc-zero
|
||||
license: by-nc-sa
|
||||
# Available values: big | small
|
||||
size: small
|
||||
sidebar: false
|
||||
post: false
|
||||
# You can set a language value if you prefer a translated version of CC license, e.g. deed.zh
|
||||
# CC licenses are available in 39 languages, you can find the specific and correct abbreviation you need on https://creativecommons.org
|
||||
language:
|
||||
|
||||
|
||||
|
||||
@ -170,3 +170,8 @@ canvas_ribbon:
|
||||
unavailable:
|
||||
- cdnjs
|
||||
integrity: sha256-UkSSapoJqxvq+8bSCIrAhXO+aOMBRmkK6vxjTstemLs=
|
||||
creative_commons:
|
||||
name: '@creativecommons/vocabulary'
|
||||
version: 2020.11.3
|
||||
dir: assets/license_badges
|
||||
alias: creativecommons-vocabulary
|
||||
|
||||
@ -89,7 +89,7 @@
|
||||
|
||||
{%- if theme.creative_commons.license and theme.creative_commons.sidebar %}
|
||||
<div class="cc-license site-overview-item animated" itemprop="license">
|
||||
{%- set ccImage = '<img src="' + url_for(theme.images + '/cc-' + theme.creative_commons.license + '.svg') + '" alt="Creative Commons">' %}
|
||||
{%- set ccImage = '<img src="' + theme.vendors.creative_commons.url + '" alt="Creative Commons">' %}
|
||||
{{ next_url(ccURL, ccImage, {class: 'cc-opacity'}) }}
|
||||
</div>
|
||||
{%- endif %}
|
||||
|
||||
@ -4,6 +4,7 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const yaml = require('js-yaml');
|
||||
const { url_for } = require('hexo-util');
|
||||
|
||||
let internal;
|
||||
try {
|
||||
internal = require('@next-theme/plugins');
|
||||
@ -13,7 +14,7 @@ const vendorsFile = fs.readFileSync(path.join(__dirname, '../../../_vendors.yml'
|
||||
const dependencies = yaml.load(vendorsFile);
|
||||
|
||||
module.exports = hexo => {
|
||||
const { vendors } = hexo.theme.config;
|
||||
const { vendors, creative_commons } = hexo.theme.config;
|
||||
if (typeof internal === 'function') {
|
||||
internal(hexo, dependencies);
|
||||
}
|
||||
@ -26,6 +27,9 @@ module.exports = hexo => {
|
||||
};
|
||||
continue;
|
||||
}
|
||||
if (key === 'creative_commons') {
|
||||
value.file = `${value.dir}/${creative_commons.size}/${creative_commons.license.replace(/-/g, '_')}.svg`;
|
||||
}
|
||||
const { name, version, file, alias, unavailable } = value;
|
||||
const links = {
|
||||
local : url_for.call(hexo, `lib/${name}/${file}`),
|
||||
|
||||
@ -21,7 +21,7 @@ hexo.extend.filter.register('template_locals', locals => {
|
||||
// See https://github.com/hexojs/hexo/pull/4614
|
||||
page.lang = page.lang || page.language;
|
||||
// Creative Commons
|
||||
locals.ccURL = 'https://creativecommons.org/' + (theme.creative_commons.license === 'zero' ? 'publicdomain/zero/1.0/' : 'licenses/' + theme.creative_commons.license + '/4.0/') + (theme.creative_commons.language || '');
|
||||
locals.ccURL = 'https://creativecommons.org/' + (theme.creative_commons.license === 'cc-zero' ? 'publicdomain/zero/1.0/' : 'licenses/' + theme.creative_commons.license + '/4.0/') + (theme.creative_commons.language || '');
|
||||
// PJAX
|
||||
locals.pjax = theme.pjax ? ' data-pjax' : '';
|
||||
// Front-matter
|
||||
|
||||
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 5.6 KiB |