diff --git a/_config.yml b/_config.yml index 93af56c012..57cbdc4bdb 100644 --- a/_config.yml +++ b/_config.yml @@ -910,6 +910,11 @@ mermaid: cdn: //cdn.jsdelivr.net/npm/mermaid@8/dist/mermaid.min.js #cdn: //cdnjs.cloudflare.com/ajax/libs/mermaid/8.0.0/mermaid.min.js +# Caniuse tag +caniuse: + enable: false + cdn: //cdn.jsdelivr.net/gh/ireade/caniuse-embed@1/caniuse-embed.min.js + # --------------------------------------------------------------- # Animation Settings diff --git a/layout/_layout.swig b/layout/_layout.swig index cd01de7482..fe396b0220 100644 --- a/layout/_layout.swig +++ b/layout/_layout.swig @@ -111,6 +111,7 @@ {% include '_third-party/math/index.swig' %} {% include '_third-party/pdf.swig' %} {% include '_third-party/mermaid.swig' %} + {% include '_third-party/caniuse.swig' %} {% include '_third-party/baidu-push.swig' %} {% include '_third-party/schedule.swig' %} {% include '_third-party/needsharebutton.swig' %} diff --git a/layout/_third-party/caniuse.swig b/layout/_third-party/caniuse.swig new file mode 100644 index 0000000000..afd3719870 --- /dev/null +++ b/layout/_third-party/caniuse.swig @@ -0,0 +1,3 @@ +{% if theme.caniuse.enable %} + +{% endif %} diff --git a/scripts/tags/caniuse.js b/scripts/tags/caniuse.js new file mode 100644 index 0000000000..14138be441 --- /dev/null +++ b/scripts/tags/caniuse.js @@ -0,0 +1,22 @@ +/** + * caniuse.js | https://theme-next.org/docs/tag-plugins/caniuse + */ + +/* global hexo */ + +'use strict'; + +const caniUse = (args) => { + args = args.join('').split('@'); + let feature = args[0]; + let periods = args[1] || 'current'; + + if (!feature) { + hexo.log.w('Caniuse feature can NOT be empty'); + return ''; + } + + return `
`; +}; + +hexo.extend.tag.register('caniuse', caniUse, {async: true});