Skip to content

Commit 9edaf4a

Browse files
committed
Closes #2790 allow png favicon
1 parent 23e2c99 commit 9edaf4a

File tree

5 files changed

+8
-11
lines changed

5 files changed

+8
-11
lines changed

site/options/output.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ Create a CNAME file in the output directory with the specified text.
262262
$ typedoc --favicon favicon.ico
263263
```
264264

265-
Specify a `favicon.ico` or `favicon.svg` file to reference as the site favicon.
265+
Specify a `.ico`, `.png` or `.svg` file to reference as the site favicon.
266266

267267
## sourceLinkExternal
268268

src/lib/internationalization/locales/en.cts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ export = {
269269
help_cname:
270270
"Set the CNAME file text, it's useful for custom domains on GitHub Pages",
271271
help_favicon:
272-
"Path to a favicon.ico or favicon.svg to include as the site icon",
272+
"Path to a .ico, .png or .svg file to include as the site icon",
273273
help_sourceLinkExternal:
274274
"Specifies that source links should be treated as external links to be opened in a new tab",
275275
help_markdownLinkExternal:
@@ -388,7 +388,7 @@ export = {
388388
"hostedBaseUrl must start with http:// or https://",
389389
useHostedBaseUrlForAbsoluteLinks_requires_hostedBaseUrl:
390390
"The useHostedBaseUrlForAbsoluteLinks option requires that hostedBaseUrl be set",
391-
favicon_must_be_ico_or_svg: "Favicon file must be either a .ico or .svg",
391+
favicon_must_be_ico_or_svg: "Favicon file must be either a .ico, .png or .svg",
392392
option_0_must_be_an_object: "The '{0}' option must be a non-array object",
393393
option_0_must_be_a_function: "The '{0}' option must be a function",
394394
option_0_must_be_object_with_urls: `{0} must be an object with string labels as keys and URL values`,

src/lib/output/plugins/AssetsPlugin.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,8 @@ export class AssetsPlugin extends RendererComponent {
4343
private onRenderBegin(event: RendererEvent) {
4444
const dest = join(event.outputDirectory, "assets");
4545

46-
switch (extname(this.favicon)) {
47-
case ".ico":
48-
copySync(this.favicon, join(dest, "favicon.ico"));
49-
break;
50-
case ".svg":
51-
copySync(this.favicon, join(dest, "favicon.svg"));
52-
break;
46+
if ([".ico", ".png", ".svg"].includes(extname(this.favicon))) {
47+
copySync(this.favicon, join(dest, "favicon" + extname(this.favicon)));
5348
}
5449

5550
if (this.customCss) {

src/lib/output/themes/default/layouts/default.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ function favicon(context: DefaultThemeRenderContext) {
1313
switch (extname(fav)) {
1414
case ".ico":
1515
return <link rel="icon" href={context.relativeURL("assets/favicon.ico", true)} />;
16+
case ".png":
17+
return <link rel="icon" href={context.relativeURL("assets/favicon.png", true)} type="image/png" />;
1618
case ".svg":
1719
return <link rel="icon" href={context.relativeURL("assets/favicon.svg", true)} type="image/svg+xml" />;
1820
default:

src/lib/utils/options/sources/typedoc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ export function addTypeDocOptions(options: Pick<Options, "addDeclaration">) {
473473
name: "favicon",
474474
help: (i18n) => i18n.help_favicon(),
475475
validate(value, i18n) {
476-
if (![".ico", ".svg"].includes(extname(value))) {
476+
if (![".ico", ".png", ".svg"].includes(extname(value))) {
477477
throw new Error(i18n.favicon_must_be_ico_or_svg());
478478
}
479479
},

0 commit comments

Comments
 (0)