helpers.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { BrandingOptions, StaticAssetDefinition, StaticAssetExtension } from './types';
  2. /**
  3. * @description
  4. * A helper function to simplify the process of setting custom branding images.
  5. *
  6. * @example
  7. * ```TypeScript
  8. * compileUiExtensions({
  9. * outputPath: path.join(__dirname, '../admin-ui'),
  10. * extensions: [
  11. * setBranding({
  12. * smallLogoPath: path.join(__dirname, 'images/my-logo-sm.png'),
  13. * largeLogoPath: path.join(__dirname, 'images/my-logo-lg.png'),
  14. * faviconPath: path.join(__dirname, 'images/my-favicon.ico'),
  15. * }),
  16. * ],
  17. * });
  18. * ```
  19. *
  20. * @docsCategory UiDevkit
  21. * @docsPage helpers
  22. */
  23. export function setBranding(options: BrandingOptions): StaticAssetExtension {
  24. const staticAssets: StaticAssetDefinition[] = [];
  25. if (options.smallLogoPath) {
  26. staticAssets.push({
  27. path: options.smallLogoPath,
  28. rename: 'logo-75px.png',
  29. });
  30. }
  31. if (options.largeLogoPath) {
  32. staticAssets.push({
  33. path: options.largeLogoPath,
  34. rename: 'logo-300px.png',
  35. });
  36. }
  37. if (options.faviconPath) {
  38. staticAssets.push({
  39. path: options.faviconPath,
  40. rename: 'favicon.ico',
  41. });
  42. }
  43. return { staticAssets };
  44. }