diff --git a/_config.yml b/_config.yml index 8ad6332..00d6125 100644 --- a/_config.yml +++ b/_config.yml @@ -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: diff --git a/_vendors.yml b/_vendors.yml index e9ed50f..d5dd79d 100644 --- a/_vendors.yml +++ b/_vendors.yml @@ -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 diff --git a/layout/_partials/sidebar/site-overview.njk b/layout/_partials/sidebar/site-overview.njk index 73fa566..08b008e 100644 --- a/layout/_partials/sidebar/site-overview.njk +++ b/layout/_partials/sidebar/site-overview.njk @@ -89,7 +89,7 @@ {%- if theme.creative_commons.license and theme.creative_commons.sidebar %}
- {%- set ccImage = 'Creative Commons' %} + {%- set ccImage = 'Creative Commons' %} {{ next_url(ccURL, ccImage, {class: 'cc-opacity'}) }}
{%- endif %} diff --git a/scripts/events/lib/vendors.js b/scripts/events/lib/vendors.js index 421efab..e34b14b 100644 --- a/scripts/events/lib/vendors.js +++ b/scripts/events/lib/vendors.js @@ -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}`), diff --git a/scripts/filters/locals.js b/scripts/filters/locals.js index 44a5a2e..1c500b5 100644 --- a/scripts/filters/locals.js +++ b/scripts/filters/locals.js @@ -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 diff --git a/source/images/cc-by-nc-nd.svg b/source/images/cc-by-nc-nd.svg deleted file mode 100644 index 7e37337..0000000 --- a/source/images/cc-by-nc-nd.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/source/images/cc-by-nc-sa.svg b/source/images/cc-by-nc-sa.svg deleted file mode 100644 index d685321..0000000 --- a/source/images/cc-by-nc-sa.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/source/images/cc-by-nc.svg b/source/images/cc-by-nc.svg deleted file mode 100644 index 64e0230..0000000 --- a/source/images/cc-by-nc.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/source/images/cc-by-nd.svg b/source/images/cc-by-nd.svg deleted file mode 100644 index a56f8d3..0000000 --- a/source/images/cc-by-nd.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/source/images/cc-by-sa.svg b/source/images/cc-by-sa.svg deleted file mode 100644 index 47d7579..0000000 --- a/source/images/cc-by-sa.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/source/images/cc-by.svg b/source/images/cc-by.svg deleted file mode 100644 index 5b1db2b..0000000 --- a/source/images/cc-by.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/source/images/cc-zero.svg b/source/images/cc-zero.svg deleted file mode 100644 index 0c08ee6..0000000 --- a/source/images/cc-zero.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file