Updates and more
This commit is contained in:
@ -1,14 +1,18 @@
|
||||
import { l as proxyL } from 'astro-i18n'
|
||||
|
||||
import { randomBytes } from 'crypto'
|
||||
const locales = ["de"];
|
||||
|
||||
const usedIds = new Set<string>()
|
||||
export const l = (route: string) => {
|
||||
const transPath = proxyL(route)
|
||||
|
||||
export const getRandomId = () => {
|
||||
while (true) {
|
||||
const id = randomBytes(4).toString('hex')
|
||||
if (!usedIds.has(id)) {
|
||||
usedIds.add(id)
|
||||
return id
|
||||
}
|
||||
if(import.meta.env.DEV) {
|
||||
return transPath;
|
||||
}
|
||||
|
||||
let [empty, locale, ...rest] = transPath.split("/");
|
||||
if (locales.includes(locale)) {
|
||||
return "/" + rest.join("/");
|
||||
}
|
||||
|
||||
return transPath;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user