cleanup: remove routes object

This commit is contained in:
James Xylight committed 2025-02-04 16:20:32 -08:00
1 parent ddaa34dee3
commit b883b5f6e0
9 files changed
+19 -48

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
{ {
"i18n-ally.localesPaths": ["src/lib/i18n"], "i18n-ally.localesPaths": ["src/lib/i18n"],
"i18n-ally.keystyle": "nested", "i18n-ally.keystyle": "nested",
"prettier.prettierPath": "prettier" "prettier.prettierPath": ""
} }
@@ -3,8 +3,9 @@
import { Button } from 'mono-svelte' import { Button } from 'mono-svelte'
import { Icon, type IconSource } from 'svelte-hero-icons' import { Icon, type IconSource } from 'svelte-hero-icons'
import { dockProps } from '../layout/Shell.svelte' import { dockProps } from '../layout/Shell.svelte'
import type { ButtonProps } from 'mono-svelte/button/Button.svelte'
interface Props { interface Props extends ButtonProps {
label: string label: string
icon?: IconSource | undefined icon?: IconSource | undefined
href?: string | undefined href?: string | undefined
@@ -25,8 +25,6 @@
import { LINKED_INSTANCE_URL } from '$lib/instance' import { LINKED_INSTANCE_URL } from '$lib/instance'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import CommandsWrapper from './commands/CommandsWrapper.svelte' import CommandsWrapper from './commands/CommandsWrapper.svelte'
import { optimizeImageURL } from '$lib/components/lemmy/post/helpers'
import { dockProps } from '../layout/Shell.svelte'
let promptOpen: boolean = $state(false) let promptOpen: boolean = $state(false)
interface Props { interface Props {
@@ -223,9 +223,6 @@
} }
} }
afterNavigate(() => {
// open = false
})
$effect(() => { $effect(() => {
if (open) search = '' if (open) search = ''
}) })
+9 -7
View File
@@ -62,13 +62,6 @@
'square-xl': 'w-12 h-12', 'square-xl': 'w-12 h-12',
custom: '', custom: '',
} }
</script>
<script lang="ts">
import type { HTMLButtonAttributes } from 'svelte/elements'
import Spinner from '../loader/Spinner.svelte'
import type { Snippet } from 'svelte'
type ButtonRoundness = 'pill' | 'xl' | 'lg' | 'md' | 'none' type ButtonRoundness = 'pill' | 'xl' | 'lg' | 'md' | 'none'
type ButtonRoundingSide = 'all' | 'left' | 'right' | 'top' | 'bottom' type ButtonRoundingSide = 'all' | 'left' | 'right' | 'top' | 'bottom'
@@ -136,6 +129,15 @@
[key: string]: any [key: string]: any
} }
export type { Props as ButtonProps }
</script>
<script lang="ts">
import type { HTMLButtonAttributes } from 'svelte/elements'
import Spinner from '../loader/Spinner.svelte'
import type { Snippet } from 'svelte'
let { let {
loading = false, loading = false,
submit = false, submit = false,
+1 -1
View File
@@ -5,7 +5,7 @@ import { browser } from '$app/environment'
type AnyFunction = (...args: any[]) => any type AnyFunction = (...args: any[]) => any
export const awaitIfServer = async <T>( export const awaitIfServer = async <T>(
promise: Promise<T> promise: Promise<T>,
): Promise<{ ): Promise<{
data: Promise<T> | T data: Promise<T> | T
}> => ({ data: browser ? promise : await promise }) }> => ({ data: browser ? promise : await promise })
+1 -1
View File
@@ -88,7 +88,7 @@ const config: Config = {
loader: async () => (await import('./i18n/zh-Hant.json')).default, loader: async () => (await import('./i18n/zh-Hant.json')).default,
}, },
], ],
fallbackLocale: 'en', fallbackLocale: 'en'
} }
export const aliases = new Map([ export const aliases = new Map([
+5 -29
View File
@@ -12,7 +12,7 @@ import { site } from './lemmy'
// Example: findClosestNumber([8, 16, 32, 64, 128], 76) will return 128 // Example: findClosestNumber([8, 16, 32, 64, 128], 76) will return 128
export const findClosestNumber = (numbers: number[], target: number): number => export const findClosestNumber = (numbers: number[], target: number): number =>
numbers.reduce((prev, curr) => numbers.reduce((prev, curr) =>
curr >= target && (prev < target || curr < prev) ? curr : prev curr >= target && (prev < target || curr < prev) ? curr : prev,
) )
export const searchParam = ( export const searchParam = (
@@ -64,7 +64,7 @@ export const placeholders = {
export function moveItem<T>( export function moveItem<T>(
array: T[], array: T[],
currentIndex: number, currentIndex: number,
newIndex: number newIndex: number,
): T[] { ): T[] {
if ( if (
currentIndex < 0 || currentIndex < 0 ||
@@ -110,34 +110,10 @@ export const DOMAIN_REGEX_FORMS =
export const isSubscribed = (subscribed: SubscribedType) => export const isSubscribed = (subscribed: SubscribedType) =>
subscribed == 'Pending' || subscribed == 'Subscribed' subscribed == 'Pending' || subscribed == 'Subscribed'
export const routes = {
'/': 'Frontpage',
get '/post/[instance]/[id=integer]'() {
return get(page)?.data?.post?.post_view?.post?.name
},
'/settings': 'Settings',
'/communities': 'Communities',
'/search': 'Search',
'/moderation': 'Moderation',
'/create/post': 'Create post',
'/create/community': 'Create community',
get '/c/[name]'() {
return get(page)?.data?.community?.community_view?.community?.title
},
'/accounts': 'Accounts',
'/admin/config': 'Administration',
'/inbox': 'Inbox',
'/saved': 'Saved',
'/about': 'About',
'/profile/user': 'Profile',
'/profile/settings': 'Profile Settings',
'/profile/blocks': 'Blocks',
}
export async function uploadImage( export async function uploadImage(
image: File | null | undefined, image: File | null | undefined,
instance: string, instance: string,
jwt: string jwt: string,
): Promise<string | undefined> { ): Promise<string | undefined> {
if (!image) return if (!image) return
@@ -161,7 +137,7 @@ export async function uploadImage(
{ {
method: 'POST', method: 'POST',
body: formData, body: formData,
} },
) )
const json = await response.json() const json = await response.json()
@@ -173,7 +149,7 @@ export async function uploadImage(
`${ `${
(await response.text().catch((_) => undefined)) ?? (await response.text().catch((_) => undefined)) ??
'Failed to upload image' 'Failed to upload image'
}: ${response.status}: ${response.statusText}` }: ${response.status}: ${response.statusText}`,
) )
} }
} }
-3
View File
@@ -1,6 +1,4 @@
<script lang="ts"> <script lang="ts">
import { run } from 'svelte/legacy'
import Navbar from '$lib/components/ui/navbar/Navbar.svelte' import Navbar from '$lib/components/ui/navbar/Navbar.svelte'
import '../style/app.css' import '../style/app.css'
import { navigating, page } from '$app/state' import { navigating, page } from '$app/state'
@@ -26,7 +24,6 @@
import { onMount } from 'svelte' import { onMount } from 'svelte'
import { browser } from '$app/environment' import { browser } from '$app/environment'
import { Forward, Icon } from 'svelte-hero-icons' import { Forward, Icon } from 'svelte-hero-icons'
import { routes } from '$lib/util.svelte.js'
import Shell from '$lib/components/ui/layout/Shell.svelte' import Shell from '$lib/components/ui/layout/Shell.svelte'
import SiteCard from '$lib/components/lemmy/SiteCard.svelte' import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
import { site } from '$lib/lemmy.js' import { site } from '$lib/lemmy.js'