mirror of
https://github.com/Unkn0wnCat/KevinK.dev.js.git
synced 2025-06-07 13:12:02 +02:00
Remove deprecated code
This commit is contained in:
parent
5e4bfe8a7c
commit
03119444a1
2 changed files with 0 additions and 89 deletions
|
@ -1,31 +0,0 @@
|
||||||
// For more information, see https://fab.dev/kb/configuration
|
|
||||||
{
|
|
||||||
plugins: {
|
|
||||||
'./src/server/languageRedirect.js': {},
|
|
||||||
'@fab/input-static': {
|
|
||||||
dir: 'public'
|
|
||||||
},
|
|
||||||
'@fab/plugin-render-html': {
|
|
||||||
fallback: false
|
|
||||||
},
|
|
||||||
'@fab/plugin-rewire-assets': {}
|
|
||||||
// This section defines your build & runtime toolchains. See https://fab.dev/kb/plugins
|
|
||||||
},
|
|
||||||
settings: {
|
|
||||||
// This section defines the variables that are injected, depending on environment.
|
|
||||||
// See https://fab.dev/kb/settings for more info.
|
|
||||||
production: {
|
|
||||||
// This environment is special. These variables get compiled into the FAB itself,
|
|
||||||
// allowing for many production-specific optimisations. See https://fab.dev/kb/production
|
|
||||||
// Example setting:
|
|
||||||
// API_URL: 'https://api.example.com/graphql'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
deploy: {
|
|
||||||
// For manual (command-line) deploys, add configuration here.
|
|
||||||
// • See https://fab.dev/guides/deploying for more info.
|
|
||||||
// However, we recommend automatic deploys (triggered by git push)
|
|
||||||
// using a service such as Linc (https://linc.sh)
|
|
||||||
// • See https://fab.dev/kb/automatic-deploys for setup instructions.
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,58 +0,0 @@
|
||||||
/* eslint-disable no-undef */
|
|
||||||
const config = require("../../config");
|
|
||||||
const locale = require("locale");
|
|
||||||
|
|
||||||
let supported = new locale.Locales(config.languages);
|
|
||||||
let defaultLang = "en";
|
|
||||||
|
|
||||||
export default ({ Router }) => {
|
|
||||||
Router.on("*", checkLang);
|
|
||||||
};
|
|
||||||
|
|
||||||
async function checkLang({ request }) {
|
|
||||||
const { url } = request
|
|
||||||
|
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
let requestURL = new URL(url);
|
|
||||||
|
|
||||||
if (requestURL.pathname.startsWith("/assets") ||
|
|
||||||
requestURL.pathname.startsWith("/icons") ||
|
|
||||||
requestURL.pathname.startsWith("/manifest.webmanifest") ||
|
|
||||||
requestURL.pathname.startsWith("/favicon") ||
|
|
||||||
requestURL.pathname.startsWith("/sw.js") ||
|
|
||||||
requestURL.pathname.startsWith("/api")) {
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < config.languages.length; i++) {
|
|
||||||
const language = config.languages[i];
|
|
||||||
|
|
||||||
if (requestURL.pathname.startsWith("/" + language)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let headers = request.headers;
|
|
||||||
|
|
||||||
let selectedLanguage = defaultLang;
|
|
||||||
|
|
||||||
if (headers.has("Accept-Language")) {
|
|
||||||
let languageHeader = headers.get("Accept-Language");
|
|
||||||
|
|
||||||
let requestLocales = new locale.Locales(languageHeader);
|
|
||||||
|
|
||||||
selectedLanguage = requestLocales.best(supported);
|
|
||||||
}
|
|
||||||
|
|
||||||
requestURL.pathname = "/" + selectedLanguage + requestURL.pathname;
|
|
||||||
|
|
||||||
///return Response.redirect(requestURL.toString(), 302);
|
|
||||||
|
|
||||||
return new Response(null, {
|
|
||||||
status: 302,
|
|
||||||
headers: {
|
|
||||||
Location: requestURL.toString(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue