diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-04-22 14:39:37 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-04-22 14:39:37 -0300 |
commit | d1319becac318e3ee46b6bb55b722eaf133628aa (patch) | |
tree | 950f4e5d86529f06abd5aaedce042105dc762118 /src | |
parent | bc08bf2a2dc9ae6f07eb525d74ee5290294df516 (diff) |
web-routes: use web route for favicon.ico
Lets live-dev-server have a favicon.
Diffstat (limited to 'src')
-rw-r--r-- | src/web-routes.js | 8 | ||||
-rw-r--r-- | src/write/build-modes/static-build.js | 40 |
2 files changed, 9 insertions, 39 deletions
diff --git a/src/web-routes.js b/src/web-routes.js index b93607d6..a49f6d0e 100644 --- a/src/web-routes.js +++ b/src/web-routes.js @@ -103,6 +103,14 @@ export async function identifyDynamicWebRoutes({ to: ['thumb.root'], statically: 'symlink', }, + + // {statically: 'copy'} is not workable for individual files + // at the moment, so this remains a symlink. + { + from: path.join(path.resolve(mediaPath), 'favicon.ico'), + to: ['shared.path', 'favicon.ico'], + statically: 'symlink', + }, ]), () => { diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js index 2baed816..d363811d 100644 --- a/src/write/build-modes/static-build.js +++ b/src/write/build-modes/static-build.js @@ -1,15 +1,6 @@ +import {cp, mkdir, stat, symlink, writeFile, unlink} from 'node:fs/promises'; import * as path from 'node:path'; -import { - copyFile, - cp, - mkdir, - stat, - symlink, - writeFile, - unlink, -} from 'node:fs/promises'; - import {rimraf} from 'rimraf'; import {quickLoadContentDependencies} from '#content-dependencies'; @@ -166,11 +157,6 @@ export async function go({ }); if (writeAll) { - await writeFavicon({ - mediaPath, - outputPath, - }); - await writeSharedFilesAndPages({ outputPath, randomLinkDataJSON: generateRandomLinkDataJSON({wikiData}), @@ -595,30 +581,6 @@ async function writeWebRouteCopies({ } } -async function writeFavicon({ - mediaPath, - outputPath, -}) { - const faviconFile = 'favicon.ico'; - - try { - await stat(path.join(mediaPath, faviconFile)); - } catch (error) { - return; - } - - try { - await copyFile( - path.join(mediaPath, faviconFile), - path.join(outputPath, faviconFile)); - } catch (error) { - logWarn`Failed to copy favicon! ${error.message}`; - return; - } - - logInfo`Copied favicon to site root.`; -} - async function writeSharedFilesAndPages({ outputPath, randomLinkDataJSON, |