Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
style: update user social card font weight
Browse files Browse the repository at this point in the history
  • Loading branch information
OgDev-01 committed Jun 7, 2023
1 parent e8e436a commit bf6c9dd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
7 changes: 7 additions & 0 deletions src/social-card/user-card/user-card.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export class UserCardService {
);

const interArrayBuffer = await fs.readFile("node_modules/@fontsource/inter/files/inter-all-400-normal.woff");
const interArrayBufferMedium = await fs.readFile("node_modules/@fontsource/inter/files/inter-all-500-normal.woff");

const svg = await satori(template, {
width: 1200,
Expand All @@ -110,6 +111,12 @@ export class UserCardService {
weight: 400,
style: "normal",
},
{
name: "Inter",
data: interArrayBufferMedium,
weight: 500,
style: "normal",
},
],
tailwindConfig,
});
Expand Down
8 changes: 4 additions & 4 deletions test/local-dev/HighlightCards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const testHighlights = [102, 101, 103];

const folderPath = "dist";

async function testHighlightCards () {
async function testHighlightCards() {
const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule] }).compile();

const app = moduleFixture.createNestApplication();
Expand All @@ -17,13 +17,13 @@ async function testHighlightCards () {

const instance = app.get(HighlightCardService);

const promises = testHighlights.map(async id => {
const { svg } = await instance.generateCardBuffer(id);
const promises = testHighlights.map(async (id) => {
const { png } = await instance.generateCardBuffer(id);

if (!existsSync(folderPath)) {
await mkdir(folderPath);
}
await writeFile(`${folderPath}/${id}.svg`, svg);
await writeFile(`${folderPath}/${id}.png`, png);
});

// generating sequential: 10.5 seconds, parallel: 4.5 seconds
Expand Down
13 changes: 5 additions & 8 deletions test/local-dev/UserCards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ import { UserCardService } from "../../src/social-card/user-card/user-card.servi
import { existsSync } from "node:fs";
import { mkdir, writeFile } from "fs/promises";


const testUsernames = [
"bdougie", "deadreyo", "defunkt", "0-vortex", "Anush008", "diivi"
];
const testUsernames = ["bdougie", "deadreyo", "defunkt", "0-vortex", "Anush008", "diivi"];

const folderPath = "dist";

async function testUserCards () {
async function testUserCards() {
const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule] }).compile();

const app = moduleFixture.createNestApplication();
Expand All @@ -20,13 +17,13 @@ async function testUserCards () {

const instance = app.get(UserCardService);

const promises = testUsernames.map(async username => {
const { svg } = await instance.generateCardBuffer(username);
const promises = testUsernames.map(async (username) => {
const { png } = await instance.generateCardBuffer(username);

if (!existsSync(folderPath)) {
await mkdir(folderPath);
}
await writeFile(`${folderPath}/${username}.svg`, svg);
await writeFile(`${folderPath}/${username}.png`, png);
});

// generating sequential: 10.5 seconds, parallel: 4.5 seconds
Expand Down

0 comments on commit bf6c9dd

Please sign in to comment.