badges: refactoring frontend plugin.
Signed-off-by: Andreas Stenius <git@astekk.se>
This commit is contained in:
committed by
Fredrik Adelöw
parent
323ec6f7ca
commit
8bf248799d
Vendored
+25
@@ -72,6 +72,31 @@ export interface Config {
|
||||
* 'for-the-badge' or 'social'.
|
||||
*/
|
||||
style?: 'plastic' | 'flat' | 'flat-square' | 'for-the-badge' | 'social';
|
||||
|
||||
/**
|
||||
* Badge title, used as tooltip text in the markdown code.
|
||||
*
|
||||
* @visibility frontend
|
||||
*/
|
||||
title?: string;
|
||||
|
||||
/**
|
||||
* Badge description, used as alt text in the markdown code.
|
||||
* Defaults to badge id.
|
||||
*
|
||||
* @visibility frontend
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
/**
|
||||
* Badge link URL, turns badge into a link in the markdown code.
|
||||
*
|
||||
* For `entity` badges, there is a `entity_url` in the context
|
||||
* that could be appropriate to use here.
|
||||
*
|
||||
* @visibility frontend
|
||||
*/
|
||||
link?: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -54,6 +54,15 @@ export class DefaultBadgeBuilder implements BadgeBuilder {
|
||||
|
||||
switch (options.format) {
|
||||
case 'json':
|
||||
if (badge.title) {
|
||||
params.title = this.render(badge.title, context);
|
||||
}
|
||||
if (badge.description) {
|
||||
params.description = this.render(badge.description, context);
|
||||
}
|
||||
if (badge.link) {
|
||||
params.link = this.render(badge.link, context);
|
||||
}
|
||||
return JSON.stringify(
|
||||
{
|
||||
badge: params,
|
||||
|
||||
@@ -21,7 +21,9 @@ export interface BadgeConfig {
|
||||
color?: string;
|
||||
labelColor?: string;
|
||||
style?: 'plastic' | 'flat' | 'flat-square' | 'for-the-badge' | 'social';
|
||||
links?: [string, string];
|
||||
title?: string;
|
||||
description?: string;
|
||||
link?: string;
|
||||
}
|
||||
|
||||
export type BadgeOptions = {
|
||||
|
||||
Reference in New Issue
Block a user