mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
#12: Fix static serve of manifest & robots
This commit is contained in:
parent
80151c2b2f
commit
5d6375d845
@ -85,6 +85,10 @@ const app = startTrilium({
|
||||
|
||||
getInitialTheme() {
|
||||
return electron.nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
|
||||
}
|
||||
},
|
||||
|
||||
registerAdditionalMiddleware(app) {
|
||||
// No additional express middleware required on Electron.
|
||||
},
|
||||
});
|
||||
electronRouting(app);
|
@ -33,11 +33,10 @@ function buildApp(appConfig: AppConfig) {
|
||||
app.use(express.raw({ limit: '500mb' }));
|
||||
app.use(express.urlencoded({ extended: false }));
|
||||
app.use(cookieParser());
|
||||
app.use(express.static(path.join(__dirname, 'public/root')));
|
||||
app.use(`/manifest.webmanifest`, express.static(path.join(__dirname, 'public/manifest.webmanifest')));
|
||||
app.use(`/robots.txt`, express.static(path.join(__dirname, 'public/robots.txt')));
|
||||
app.use(express.static(path.join(__dirname, 'public/root')));
|
||||
app.use(sessionParser);
|
||||
app.use(favicon(`${__dirname}/../../common/images/app-icons/win/icon.ico`));
|
||||
appConfig.registerAdditionalMiddleware(app);
|
||||
|
||||
require('./routes/assets').register(app);
|
||||
require('./routes/routes').register(app, appConfig);
|
||||
|
@ -1,4 +1,6 @@
|
||||
import startTrilium = require("./www");
|
||||
import path = require("path");
|
||||
import express = require("express");
|
||||
|
||||
startTrilium({
|
||||
setupCompleteCallback: (res) => {
|
||||
@ -8,5 +10,11 @@ startTrilium({
|
||||
getInitialTheme() {
|
||||
// default based on the poll in https://github.com/zadam/trilium/issues/2516
|
||||
return "dark";
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
registerAdditionalMiddleware(app) {
|
||||
const assetsDir = path.join(__dirname, "..", "..", "client", "assets");
|
||||
app.use(`/manifest.webmanifest`, express.static(path.join(assetsDir, 'manifest.webmanifest')));
|
||||
app.use(`/robots.txt`, express.static(path.join(assetsDir, 'robots.txt')));
|
||||
},
|
||||
});
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Response } from "express";
|
||||
import type { Express } from "express";
|
||||
|
||||
export type InitialThemeCallback = () => "dark" | "light";
|
||||
|
||||
@ -18,6 +19,13 @@ export interface InitDbOptions {
|
||||
* Handles differences between clients, for example allowing different behaviour when running from the web server versus the desktop application.
|
||||
*/
|
||||
export interface AppConfig extends InitDbOptions {
|
||||
/**
|
||||
* Called when the express app is built, in order to define additional middleware that might be specific to a web or desktop application.
|
||||
*
|
||||
* @param app the express app to add the middleware on.
|
||||
*/
|
||||
registerAdditionalMiddleware: (app: Express) => void;
|
||||
|
||||
/** Callback to be invoked when first setup is complete. */
|
||||
setupCompleteCallback: SetupCompleteCallback;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user