feat: add legal page with configuration options (#724)

* Addconfig entries for legal notice

* Add legal route handling to middleware

* Make legal notice public

* Add legal category to config sidebar

* Add legal notice page

* Add German translations for legal notice and configuration options

* Replace legal page with separate imprint and privacy pages

* Update middleware

* Add footer component

* Update legal text descriptions to indicate Markdown support again

* Refactor footer layout

* Add zIndex to footer component

* improve mobile layout

* run formatter

---------

Co-authored-by: Elias Schneider <login@eliasschneider.com>
This commit is contained in:
Aaron
2025-01-02 17:29:01 +01:00
committed by GitHub
parent 53c05518df
commit df1ffaa2bc
12 changed files with 297 additions and 15 deletions

View File

@@ -14,7 +14,14 @@ export const config = {
export async function middleware(request: NextRequest) {
const routes = {
unauthenticated: new Routes(["/auth/*", "/"]),
public: new Routes(["/share/*", "/s/*", "/upload/*", "/error"]),
public: new Routes([
"/share/*",
"/s/*",
"/upload/*",
"/error",
"/imprint",
"/privacy",
]),
admin: new Routes(["/admin/*"]),
account: new Routes(["/account*"]),
disabled: new Routes([]),
@@ -55,6 +62,20 @@ export async function middleware(request: NextRequest) {
routes.disabled.routes.push("/auth/resetPassword*");
}
if (!getConfig("legal.enabled")) {
routes.disabled.routes.push("/imprint", "/privacy");
} else {
if (!getConfig("legal.imprintText") && !getConfig("legal.imprintUrl")) {
routes.disabled.routes.push("/imprint");
}
if (
!getConfig("legal.privacyPolicyText") &&
!getConfig("legal.privacyPolicyUrl")
) {
routes.disabled.routes.push("/privacy");
}
}
// prettier-ignore
const rules = [
// Disabled routes
@@ -86,6 +107,16 @@ export async function middleware(request: NextRequest) {
condition: (!getConfig("general.showHomePage") || user) && route == "/",
path: "/upload",
},
// Imprint redirect
{
condition: route == "/imprint" && !getConfig("legal.imprintText") && getConfig("legal.imprintUrl"),
path: getConfig("legal.imprintUrl"),
},
// Privacy redirect
{
condition: route == "/privacy" && !getConfig("legal.privacyPolicyText") && getConfig("legal.privacyPolicyUrl"),
path: getConfig("legal.privacyPolicyUrl"),
},
];
for (const rule of rules) {
if (rule.condition) {