UNPKG

hexo-butterfly-tag-plugins-plus-chinese

Version:

A number of tag plugins for theme-butterfly

48 lines (45 loc) 1.33 kB
/** * https://github.com/anuraghazra/github-readme-stats */ 'use strict'; // {% gh卡片 volantis-x %} // {% gh卡片 volantis-x/hexo-theme-volantis %} function ghCard(args) { args = args.join(' ').split(', '); let path = args[0].trim(); let card = ''; card += '<a class="ghcard" rel="external nofollow noopener noreferrer" href="https://github.com/' + path + '">'; let url = ''; if (path.includes('/')) { // is repo let ps = path.split('/'); url += 'https://github-readme-stats.vercel.app/api/pin/?username=' + ps[0] + "&repo=" + ps[1]; } else { // is user url += 'https://github-readme-stats.vercel.app/api/?username=' + path; } if (args.length > 1) { for (let i = 1; i < args.length; i++) { let tmp = args[i].trim(); url += "&" + tmp; } } if (!url.includes('&show_owner=')) { url += '&show_owner=true'; } card += '<img src="' + url + '"/>'; card += '</a>'; return card; } hexo.extend.tag.register('gh卡片', ghCard); hexo.extend.tag.register('ghcard', ghCard); function ghCardGroup(args, content) { let ret = ''; // wrap ret += '<div class="ghcard-group">'; ret += content; ret += '</div>'; return ret; } hexo.extend.tag.register('gh卡片组', ghCardGroup, {ends: true}); hexo.extend.tag.register('ghcardgroup', ghCardGroup, {ends: true});