diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 758fc75..ce3177e 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -185,8 +185,20 @@ const config: Config = { } satisfies Preset.ThemeConfig, plugins: [ - 'docusaurus-plugin-image-zoom' - ] + 'docusaurus-plugin-image-zoom', + // Icons in addition to the "favicon" above. Unlike the "headTags" option, a plugin knows the base url + // of the locale being built (/ru/, /en/), where the static files are located + (context) => ({ + name: 'site-icons', + injectHtmlTags: () => ({ + headTags: [ + {tagName: 'link', attributes: {rel: 'icon', type: 'image/svg+xml', href: `${context.baseUrl}img/favicon.svg`}}, + {tagName: 'link', attributes: {rel: 'apple-touch-icon', href: `${context.baseUrl}img/apple-touch-icon.png`}}, + {tagName: 'link', attributes: {rel: 'manifest', href: `${context.baseUrl}site.webmanifest`}}, + ], + }), + }), + ], }; export default config; diff --git a/scripts/postbuild.mjs b/scripts/postbuild.mjs index 11afe50..22d463a 100644 --- a/scripts/postbuild.mjs +++ b/scripts/postbuild.mjs @@ -42,6 +42,9 @@ cpSync(join(projectDir, 'root'), buildDir, {recursive: true}); // GitHub Pages only serves the 404.html from the site root copyFileSync(join(buildDir, DEFAULT_PREFIX, '404.html'), join(buildDir, '404.html')); +// Browsers and other clients request /favicon.ico when a page doesn't declare its icons +copyFileSync(join(buildDir, DEFAULT_PREFIX, 'img', 'favicon.ico'), join(buildDir, 'favicon.ico')); + // The site root redirects to the documentation in the browser's language const languagesMap = Object.fromEntries([ ...RUSSIAN_SPEAKING.map((lang) => [lang, DEFAULT_PREFIX]), @@ -55,6 +58,8 @@ writeFileSync(join(buildDir, 'index.html'), `