'use strict';
function getIcon (cornerOptions) {
if (!cornerOptions.icon) {
return 'Not found the icon settings'
}
const icon = cornerOptions.icon.toLowerCase();
if (icon === 'github') {
return ''
}
if (icon === 'gitlab') {
return ''
}
if (icon === 'spring') {
return ''
}
if (icon === 'spring2') {
return ''
}
if (icon === 'golang') {
return ''
}
// if the icon is not in the preset, it should be the image url
const width = cornerOptions.width ? cornerOptions.width : cornerOptions.height ? cornerOptions.height : 100;
const heitht = cornerOptions.height ? cornerOptions.height : cornerOptions.width ? cornerOptions.width : 100;
return ``
}
const cornerOptions = {
// the widtH of the icon image
width: '',
// the height of the icon image
height: '',
// the repo url
url: '',
// the target, align to site by default
target:'',
// the icon name/url
icon: '',
// the text of the title attribute is displayed as a tooltip
title: '',
// the corner background color, default false to use default color
background: false,
// the icon color, default false to use default color
color: false
};
function corner (hook, vm) {
// check if config the repo
if (!window.$docsify.repo) {
return
}
hook.mounted(function () {
const a = document.querySelector('a.github-corner');
a.innerHTML = getIcon(cornerOptions);
cornerOptions.url && (a.href = cornerOptions.url);
cornerOptions.title && (a.title = cornerOptions.title);
if(cornerOptions.target){
a.target = cornerOptions.target;
}
// icon color config
const cl = document.querySelector('.github-corner svg');
if (cl && cornerOptions.background) {
cl.style.setProperty('fill', cornerOptions.background);
}
if (cl && cornerOptions.color) {
cl.style.setProperty('color', cornerOptions.color);
}
});
}
// find corner plugin options
window.$docsify.corner = Object.assign(
cornerOptions,
window.$docsify.corner
);
window.$docsify.plugins = [].concat(corner, window.$docsify.plugins);