Skip to content

Commit

Permalink
feat: Allow changing favicon paths (#586)
Browse files Browse the repository at this point in the history
* feat: Allow changing favicon paths

* Update README
  • Loading branch information
goferito authored Jun 17, 2023
1 parent 23cc721 commit 8661f45
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 8 deletions.
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const app = express();
app.use('/admin/queues', serverAdapter.getRouter());

// other configurations of your server

app.listen(3000, () => {
console.log('Running on 3000...');
console.log('For the UI, open http://localhost:3000/admin/queues');
Expand All @@ -106,12 +106,14 @@ For more advanced usages check the `examples` folder, currently it contains:
7. [With Nest.js server using the express adapter](https://github.com/felixmosh/bull-board/tree/master/examples/with-nestjs) (Thanx to @lodi-g)

### Board options
1. `uiConfig.boardTitle` (default: `empty`)
The Board title
1. `uiConfig.boardTitle` (default: `Bull Dashboard`)
The Board and page titles
2. `uiConfig.boardLogo` (default: `empty`) `{ path: string; width?: number | string; height?: number | string }`
An object that allows you to specify a different logo
3. `uiConfig.miscLinks` (default: `empty`) `Array< { text: string; url: string }>`
An array of misc link that you can add to the dashboard, such as logout link.
4. uiConfig.favIcon (default: `{ default: 'static/images/logo.svg', alternative: 'static/favicon-32x32.png', }`) `{ default: string; alternative: 'string' }`
An object that allows you to specify the default and alternative favicons.

```js
const QueueMQ = require('bullmq');
Expand All @@ -126,8 +128,16 @@ createBullBoard({
options: {
uiConfig: {
boardTitle: 'My BOARD',
boardLogo: {path: 'https://cdn.my-domain.com/logo.png', width: '100px', height: 200},
boardLogo: {
path: 'https://cdn.my-domain.com/logo.png',
width: '100px',
height: 200,
},
miscLinks: [{text: 'Logout', url: '/logout'}],
favIcon: {
default: 'static/images/logo.svg',
alternative: 'static/favicon-32x32.png',
},
},
},
});
Expand Down Expand Up @@ -224,7 +234,7 @@ createBullBoard({
queues: [
new BullAdapter(someQueue),
],
serverAdapter
serverAdapter
})

// ... express server configuration
Expand Down
8 changes: 7 additions & 1 deletion packages/api/src/handlers/entryPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ export function entryPoint(params: {

return {
name: 'index.ejs',
params: { basePath, uiConfig, title: params.uiConfig.boardTitle as string },
params: {
basePath,
uiConfig,
title: params.uiConfig.boardTitle as string,
favIconDefault: params.uiConfig.favIcon?.default as string,
favIconAlternative: params.uiConfig.favIcon?.alternative as string,
},
};
}
4 changes: 4 additions & 0 deletions packages/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export function createBullBoard({
.setStaticPath('/static', path.join(uiBasePath, 'dist/static'))
.setUIConfig({
boardTitle: 'Bull Dashboard',
favIcon: {
default: 'static/images/logo.svg',
alternative: 'static/favicon-32x32.png',
},
...options.uiConfig,
})
.setEntryRoute(appRoutes.entryPoint)
Expand Down
6 changes: 6 additions & 0 deletions packages/api/typings/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,10 @@ export type UIConfig = Partial<{
boardTitle: string;
boardLogo: { path: string; width?: number | string; height?: number | string };
miscLinks: Array<IMiscLink>;
favIcon: FavIcon;
}>;

export type FavIcon = {
default: string;
alternative: string;
};
4 changes: 2 additions & 2 deletions packages/ui/src/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<meta name="robots" content="noindex" />
<base href="<%= basePath %>" />
<title><%= title %></title>
<link rel="alternate icon" type="image/png" href="static/favicon-32x32.png">
<link rel="icon" type="image/svg+xml" id="fav-logo" href="static/images/logo.svg">
<link rel="alternate icon" type="image/png" href="<%= favIconAlternative %>">
<link rel="icon" type="image/svg+xml" id="fav-logo" href="<%= favIconDefault %>">
<link href="https://fonts.googleapis.com/css2?family=Ubuntu:wght@300;400;500&display=swap" rel="stylesheet">
</head>
<body>
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ module.exports = {
basePath,
uiConfig: '<%- uiConfig %>',
title: '<%= title %>',
favIconDefault: '<%= favIconDefault %>',
favIconAlternative: '<%= favIconAlternative %>',
},
inject: 'body',
}),
Expand Down

0 comments on commit 8661f45

Please sign in to comment.