Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Upload SVG logo using Theme Editor #582

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,42 @@ export class ThemeEditorStylesAdminController {
new FilesValidationPipe({
logo_dark: {
maxSize: 1024 * 1024, // 1 MB
acceptMimeType: ['image/png', 'image/jpeg'],
acceptMimeType: [
'image/png',
'image/jpeg',
'image/svg+xml',
'image/webp',
],
isOptional: true,
},
mobile_logo_dark: {
maxSize: 1024 * 1024, // 1 MB
acceptMimeType: ['image/png', 'image/jpeg'],
acceptMimeType: [
'image/png',
'image/jpeg',
'image/svg+xml',
'image/webp',
],
isOptional: true,
},
logo_light: {
maxSize: 1024 * 1024, // 1 MB
acceptMimeType: ['image/png', 'image/jpeg'],
acceptMimeType: [
'image/png',
'image/jpeg',
'image/svg+xml',
'image/webp',
],
isOptional: true,
},
mobile_logo_light: {
maxSize: 1024 * 1024, // 1 MB
acceptMimeType: ['image/png', 'image/jpeg'],
acceptMimeType: [
'image/png',
'image/jpeg',
'image/svg+xml',
'image/webp',
],
isOptional: true,
},
}),
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/helpers/files/files-helper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const acceptMimeTypeImage = [
'image/webp',
'image/gif',
'image/avif',
'image/svg+xml',
];

export const acceptMimeTypeVideo = ['video/mp4', 'video/webm', 'video/ogg'];
Expand Down
22 changes: 9 additions & 13 deletions packages/backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@ export const nestjsMainApp = async (app: INestApplication, options?: Args) => {
const pkg: {
version: string;
} = JSON.parse(await readFile(join(process.cwd(), 'package.json'), 'utf-8'));
app.enableCors({
...options?.cors,
credentials: true,
origin: [
process.env.NEXT_PUBLIC_FRONTEND_URL ?? 'http://localhost:3000',
...(options?.cors?.origin ?? []),
],
});

app.use(cookieParser());
app.use(
helmet({
contentSecurityPolicy:
process.env.NODE_ENV === 'development' ? false : undefined,
crossOriginResourcePolicy: { policy: 'cross-origin' },
}),
);

Expand All @@ -48,17 +55,6 @@ export const nestjsMainApp = async (app: INestApplication, options?: Args) => {
}),
);

app.enableCors({
...options?.cors,
credentials: true,
origin: [
process.env.NEXT_PUBLIC_FRONTEND_URL
? process.env.NEXT_PUBLIC_FRONTEND_URL
: 'http://localhost:3000',
...(options?.cors?.origin ?? []),
],
});

const port = Number(process.env.PORT) || 8080;
const hostname = process.env.HOSTNAME ?? 'localhost';
await app.listen(port, hostname, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import { acceptMimeTypeImage } from '@/helpers/files-support';
import { formatBytes } from '@/helpers/format-bytes';
import {
NodeViewProps,
Expand All @@ -12,7 +13,7 @@ import React from 'react';
import Moveable from 'react-moveable';

import { CONFIG } from '../../../../helpers/config-with-env';
import { acceptMimeTypeImage, FilesHandlerAttributes } from './files';
import { FilesHandlerAttributes } from './files';

const FileComponent = ({
node: { attrs },
Expand Down
10 changes: 0 additions & 10 deletions packages/frontend/src/components/editor/extensions/files/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@ import { ShowFile } from 'vitnode-shared/files.dto';

import { renderFileNodeForReact } from './client';

export const acceptMimeTypeImage = [
'image/jpeg',
'image/png',
'image/webp',
'image/gif',
'image/avif',
];

export const acceptMimeTypeVideo = ['video/mp4', 'video/webm', 'video/ogg'];

export interface FilesHandlerAttributes {
dir_folder: string;
file_alt?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {
acceptMimeTypeImage,
acceptMimeTypeVideo,
} from '@/helpers/files-support';
import { useMiddlewareData } from '@/hooks/use-middleware-data';
import { useSession } from '@/hooks/use-session';
import { useSessionAdmin } from '@/hooks/use-session-admin';
import { FilesPermissionsCoreSessions } from 'vitnode-shared/user.dto';
import { AllowTypeFilesEnum } from 'vitnode-shared/utils/global';

import {
acceptMimeTypeImage,
acceptMimeTypeVideo,
FilesHandlerStorage,
} from '../files';
import { FilesHandlerStorage } from '../files';

export const useFilesExtensionEditor = () => {
const session = useSession();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use client';

import { acceptMimeTypeImage } from '@/helpers/files-support';
import { formatBytes } from '@/helpers/format-bytes';
import { File } from 'lucide-react';
import Image from 'next/image';
import { useTranslations } from 'next-intl';

import { CONFIG } from '../../../helpers/config-with-env';
import { Button } from '../../ui/button';
import { acceptMimeTypeImage } from '../extensions/files/files';

export const FileDownloadButton = ({
allowDownloadAttachments,
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/helpers/files-support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const acceptMimeTypeImage = [
'image/webp',
'image/gif',
'image/avif',
'image/svg+xml',
];

export const acceptMimeTypeVideo = ['video/mp4', 'video/webm', 'video/ogg'];
5 changes: 5 additions & 0 deletions packages/frontend/src/views/theme/layout/header/logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import Image from 'next/image';

export const LogoHeader = async ({ className }: { className?: string }) => {
const { logos } = await getMiddlewareData();
// console.log(
// 'logos',
// logos,
// `${CONFIG.backend_public_url}/${logos.logo_light.dir_folder}/${logos.logo_light.file_name}`,
// );

return (
<Link
Expand Down
Loading