helpers.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. * ```ts
  8. * compileUiExtensions({
  9. * outputPath: path.join(__dirname, '../admin-ui'),
  10. * extensions: [
  11. * setBranding({
  12. * // This is used as the branding in the top-left above the navigation
  13. * smallLogoPath: path.join(__dirname, 'images/my-logo-sm.png'),
  14. * // This is used on the login page
  15. * largeLogoPath: path.join(__dirname, 'images/my-logo-lg.png'),
  16. * faviconPath: path.join(__dirname, 'images/my-favicon.ico'),
  17. * }),
  18. * ],
  19. * });
  20. * ```
  21. *
  22. * @docsCategory UiDevkit
  23. * @docsPage helpers
  24. */
  25. export function setBranding(options: BrandingOptions): StaticAssetExtension {
  26. const staticAssets: StaticAssetDefinition[] = [];
  27. if (options.smallLogoPath) {
  28. staticAssets.push({
  29. path: options.smallLogoPath,
  30. rename: 'logo-top.webp',
  31. });
  32. }
  33. if (options.largeLogoPath) {
  34. staticAssets.push({
  35. path: options.largeLogoPath,
  36. rename: 'logo-login.webp',
  37. });
  38. }
  39. if (options.faviconPath) {
  40. staticAssets.push({
  41. path: options.faviconPath,
  42. rename: 'favicon.ico',
  43. });
  44. }
  45. return { staticAssets };
  46. }