diff --git a/api/index.ts b/api/index.ts index dfe8e19c..e632cca6 100644 --- a/api/index.ts +++ b/api/index.ts @@ -60,6 +60,7 @@ async function app(req: Request): Promise { const ranks: Array = params.getAll("rank").flatMap((r) => r.split(",") ).map((r) => r.trim()); + const center: boolean = params.getBooleanValue("center", CONSTANTS.DEFAULT_CENTER) if (username === null) { const [base] = req.url.split("?"); @@ -81,23 +82,9 @@ async function app(req: Request): Promise {
- +
- `, ); return new Response( @@ -139,6 +126,7 @@ async function app(req: Request): Promise { paddingHeight, noBackground, noFrame, + center ).render(userInfo, theme), { headers: defaultHeaders, diff --git a/src/card.ts b/src/card.ts index b2762b42..6a5b2dee 100644 --- a/src/card.ts +++ b/src/card.ts @@ -16,6 +16,7 @@ export class Card { private marginHeight: number, private noBackground: boolean, private noFrame: boolean, + private center: boolean, ) { this.width = panelSize * this.maxColumn + this.marginWidth * (this.maxColumn - 1); @@ -53,17 +54,16 @@ export class Card { const row = this.getRow(trophyList); this.height = this.getHeight(row); + const style = this.center ? "display: block; margin: auto;" : ""; + return ` - - ${this.renderTrophy(trophyList, theme)} - `; + + + ${this.renderTrophy(trophyList, theme)} + + `; } + private getRow(trophyList: TrophyList) { let row = Math.floor((trophyList.length - 1) / this.maxColumn) + 1; if (row > this.maxRow) { diff --git a/src/utils.ts b/src/utils.ts index 7abe0bb6..3a379f7a 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -63,6 +63,7 @@ export const CONSTANTS = { DEFAULT_GITHUB_RETRY_DELAY: 1000, REVALIDATE_TIME: HOUR_IN_MILLISECONDS, REDIS_TTL: HOUR_IN_MILLISECONDS * 4, + DEFAULT_CENTER: false, }; export enum RANK {