diff --git a/site/options/output.md b/site/options/output.md
index 626a8b8ba..152e968e6 100644
--- a/site/options/output.md
+++ b/site/options/output.md
@@ -262,7 +262,7 @@ Create a CNAME file in the output directory with the specified text.
$ typedoc --favicon favicon.ico
```
-Specify a `favicon.ico` or `favicon.svg` file to reference as the site favicon.
+Specify a `.ico`, `.png` or `.svg` file to reference as the site favicon.
## sourceLinkExternal
diff --git a/src/lib/internationalization/locales/en.cts b/src/lib/internationalization/locales/en.cts
index ff9981940..41ad6ebfd 100644
--- a/src/lib/internationalization/locales/en.cts
+++ b/src/lib/internationalization/locales/en.cts
@@ -268,8 +268,7 @@ export = {
"Path to the readme file that should be displayed on the index page. Pass `none` to disable the index page and start the documentation on the globals page",
help_cname:
"Set the CNAME file text, it's useful for custom domains on GitHub Pages",
- help_favicon:
- "Path to a favicon.ico or favicon.svg to include as the site icon",
+ help_favicon: "Path to favicon to include as the site icon",
help_sourceLinkExternal:
"Specifies that source links should be treated as external links to be opened in a new tab",
help_markdownLinkExternal:
@@ -388,7 +387,8 @@ export = {
"hostedBaseUrl must start with http:// or https://",
useHostedBaseUrlForAbsoluteLinks_requires_hostedBaseUrl:
"The useHostedBaseUrlForAbsoluteLinks option requires that hostedBaseUrl be set",
- favicon_must_be_ico_or_svg: "Favicon file must be either a .ico or .svg",
+ favicon_must_have_one_of_the_following_extensions_0:
+ "Favicon must have on of the following extensions: {0}",
option_0_must_be_an_object: "The '{0}' option must be a non-array object",
option_0_must_be_a_function: "The '{0}' option must be a function",
option_0_must_be_object_with_urls: `{0} must be an object with string labels as keys and URL values`,
diff --git a/src/lib/internationalization/locales/zh.cts b/src/lib/internationalization/locales/zh.cts
index e2ab44cdb..5770ac4a3 100644
--- a/src/lib/internationalization/locales/zh.cts
+++ b/src/lib/internationalization/locales/zh.cts
@@ -279,7 +279,7 @@ export = localeUtils.buildIncompleteTranslation({
help_readme:
"应显示在索引页上的自述文件路径。传递“none”以禁用索引页并在全局页上启动文档",
help_cname: "设置 CNAME 文件文本,这对于 GitHub Pages 上的自定义域很有用",
- help_favicon: "作为站点图标包含的 favicon.ico 或 favicon.svg 的路径",
+ help_favicon: "作为站点图标包含的 favicon 的路径",
help_sourceLinkExternal:
"指定哪些源代码链接应被视为外部链接,并在新选项卡中打开",
help_markdownLinkExternal:
@@ -371,7 +371,6 @@ export = localeUtils.buildIncompleteTranslation({
"hostingBaseUrl 必须以 http:// 或 https:// 开头",
useHostedBaseUrlForAbsoluteLinks_requires_hostedBaseUrl:
"useHostedBaseUrlForAbsoluteLinks 选项要求设置 hostingBaseUrl",
- favicon_must_be_ico_or_svg: "Favicon 文件必须是一个 .ico 或 .svg 文件",
option_0_must_be_an_object: "“{0}”选项必须是非数组对象",
option_0_must_be_a_function: "‘{0}’ 选项必须是一个函数",
option_0_must_be_object_with_urls:
diff --git a/src/lib/output/plugins/AssetsPlugin.ts b/src/lib/output/plugins/AssetsPlugin.ts
index 55b17f41f..ea55907d6 100644
--- a/src/lib/output/plugins/AssetsPlugin.ts
+++ b/src/lib/output/plugins/AssetsPlugin.ts
@@ -43,13 +43,11 @@ export class AssetsPlugin extends RendererComponent {
private onRenderBegin(event: RendererEvent) {
const dest = join(event.outputDirectory, "assets");
- switch (extname(this.favicon)) {
- case ".ico":
- copySync(this.favicon, join(dest, "favicon.ico"));
- break;
- case ".svg":
- copySync(this.favicon, join(dest, "favicon.svg"));
- break;
+ if ([".ico", ".png", ".svg"].includes(extname(this.favicon))) {
+ copySync(
+ this.favicon,
+ join(dest, "favicon" + extname(this.favicon)),
+ );
}
if (this.customCss) {
diff --git a/src/lib/output/themes/default/layouts/default.tsx b/src/lib/output/themes/default/layouts/default.tsx
index 27320f3da..7cbf20f73 100644
--- a/src/lib/output/themes/default/layouts/default.tsx
+++ b/src/lib/output/themes/default/layouts/default.tsx
@@ -13,6 +13,8 @@ function favicon(context: DefaultThemeRenderContext) {
switch (extname(fav)) {
case ".ico":
return ;
+ case ".png":
+ return ;
case ".svg":
return ;
default:
diff --git a/src/lib/utils/options/sources/typedoc.ts b/src/lib/utils/options/sources/typedoc.ts
index df2cb9a75..2ff938ff2 100644
--- a/src/lib/utils/options/sources/typedoc.ts
+++ b/src/lib/utils/options/sources/typedoc.ts
@@ -473,8 +473,13 @@ export function addTypeDocOptions(options: Pick) {
name: "favicon",
help: (i18n) => i18n.help_favicon(),
validate(value, i18n) {
- if (![".ico", ".svg"].includes(extname(value))) {
- throw new Error(i18n.favicon_must_be_ico_or_svg());
+ const allowedExtension = [".ico", ".png", ".svg"];
+ if (!allowedExtension.includes(extname(value))) {
+ throw new Error(
+ i18n.favicon_must_have_one_of_the_following_extensions_0(
+ allowedExtension.join(", "),
+ ),
+ );
}
},
type: ParameterType.Path,