fix: storybook font rendering and shared fonts module #1

Merged
ilia merged 74 commits from feat/portfolio-setup into main 2026-05-18 18:45:22 +00:00
3 changed files with 45 additions and 0 deletions
Showing only changes of commit c9631f9905 - Show all commits
+1
View File
@@ -1,6 +1,7 @@
export type { ClassValue } from 'clsx'; export type { ClassValue } from 'clsx';
export { CONTACT_LINKS } from './config/config'; export { CONTACT_LINKS } from './config/config';
export * from './fonts/fonts'; export * from './fonts/fonts';
export { buildFileUrl } from './utils/buildFileUrl/buildFileUrl';
export { cn } from './utils/cn/cn'; export { cn } from './utils/cn/cn';
export * from './utils/formatDate/formatDate'; export * from './utils/formatDate/formatDate';
export { groupByKey } from './utils/groupByKey/groupByKey'; export { groupByKey } from './utils/groupByKey/groupByKey';
@@ -0,0 +1,33 @@
import { buildFileUrl } from './buildFileUrl';
describe('buildFileUrl', () => {
describe('default base URL', () => {
it('builds correct URL with default base', () => {
expect(buildFileUrl('site_settings', 'ss1', 'cv_2024.pdf')).toBe(
'http://127.0.0.1:8090/api/files/site_settings/ss1/cv_2024.pdf',
);
});
});
describe('custom base URL', () => {
it('uses provided baseUrl when given', () => {
expect(buildFileUrl('photos', 'rec1', 'avatar.png', 'https://pb.example.com')).toBe(
'https://pb.example.com/api/files/photos/rec1/avatar.png',
);
});
});
describe('different collections, records, filenames', () => {
it('handles projects collection', () => {
expect(buildFileUrl('projects', 'proj42', 'screenshot.jpg', 'http://127.0.0.1:8090')).toBe(
'http://127.0.0.1:8090/api/files/projects/proj42/screenshot.jpg',
);
});
it('handles contacts collection', () => {
expect(buildFileUrl('contacts', 'cid99', 'photo.webp', 'http://127.0.0.1:8090')).toBe(
'http://127.0.0.1:8090/api/files/contacts/cid99/photo.webp',
);
});
});
});
@@ -0,0 +1,11 @@
/**
* Builds a URL for a file stored in a PocketBase record.
*/
export function buildFileUrl(
collectionId: string,
recordId: string,
filename: string,
baseUrl: string = process.env.NEXT_PUBLIC_PB_URL ?? 'http://127.0.0.1:8090',
): string {
return `${baseUrl}/api/files/${collectionId}/${recordId}/${filename}`;
}