Skip to content

Commit

Permalink
fix: logo and favicon configuration (#2180)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanpicado committed Apr 10, 2021
1 parent e56fd19 commit 782dd1c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
run: yarn lint
- name: Publish
run: sh scripts/publish.sh
if: ${{ github.ref == 'refs/heads/5.x' }}
env:
REGISTRY_AUTH_TOKEN: ${{ secrets.REGISTRY_AUTH_TOKEN }}
REGISTRY_URL: registry.npmjs.org
Expand Down
2 changes: 2 additions & 0 deletions conf/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ web:
# sort_packages: asc
# convert your UI to the dark side
# darkMode: true
# logo: http://somedomain/somelogo.png
# favicon: http://somedomain/favicon.ico | /path/favicon.ico

# translate your registry, api i18n not available yet
# i18n:
Expand Down
2 changes: 2 additions & 0 deletions conf/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ web:
# by default packages are ordercer ascendant (asc|desc)
# sort_packages: asc
# darkMode: true
# logo: http://somedomain/somelogo.png
# favicon: http://somedomain/favicon.ico | /path/favicon.ico

# translate your registry, api i18n not available yet
# i18n:
Expand Down
6 changes: 3 additions & 3 deletions src/api/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function serveFavicon(config: Config) {
return function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
try {
// @ts-ignore
const logoConf: string = config?.web?.logo as string;
const logoConf: string = config?.web?.favicon as string;
if (logoConf === '') {
debug('favicon disabled');
res.status(404);
Expand All @@ -42,6 +42,7 @@ export function serveFavicon(config: Config) {
) {
debug('redirect to %o', logoConf);
res.redirect(logoConf);
return;
} else {
const faviconPath = path.normalize(logoConf);
debug('serving favicon from %o', faviconPath);
Expand All @@ -52,11 +53,10 @@ export function serveFavicon(config: Config) {
} else {
res.setHeader('Content-Type', 'image/x-icon');
fs.createReadStream(faviconPath).pipe(res);
return;
debug('rendered custom ico');
}
});
}
return next();
} else {
res.setHeader('Content-Type', 'image/x-icon');
fs.createReadStream(path.join(__dirname, './web/html/favicon.ico')).pipe(res);
Expand Down
3 changes: 1 addition & 2 deletions src/api/web/html/renderHTML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export default function renderHTML(config, manifest, manifestFiles, req, res) {
const darkMode = config?.web?.darkMode ?? false;
const title = config?.web?.title ?? WEB_TITLE;
const scope = config?.web?.scope ?? '';
// FIXME: logo URI is incomplete
let logoURI = config?.web?.logo ?? '';
const version = pkgJSON.version;
const primaryColor = validatePrimaryColor(config?.web?.primary_color) ?? '#4b5e40';
Expand All @@ -56,7 +55,7 @@ export default function renderHTML(config, manifest, manifestFiles, req, res) {
base,
primaryColor,
version,
logoURI,
logo: logoURI,
title,
scope,
language,
Expand Down

0 comments on commit 782dd1c

Please sign in to comment.