diff --git a/src/app.d.ts b/src/app.d.ts
index b660ebc8..9ef481b2 100644
--- a/src/app.d.ts
+++ b/src/app.d.ts
@@ -1,5 +1,6 @@
// See https://kit.svelte.dev/docs/types#app
+import type { Action } from '$lib/components/ui/navbar/commands/actions'
import type { ComponentType, SvelteComponent } from 'svelte'
// for information about these interfaces
@@ -16,6 +17,9 @@ declare global {
props?: any
}
}
+ contextual?: {
+ actions?: Action[]
+ }
}
interface PageState {
openImage: url
diff --git a/src/lib/components/ui/navbar/commands/Commands.svelte b/src/lib/components/ui/navbar/commands/Commands.svelte
index 786731a1..3e286188 100644
--- a/src/lib/components/ui/navbar/commands/Commands.svelte
+++ b/src/lib/components/ui/navbar/commands/Commands.svelte
@@ -10,6 +10,7 @@
import { profile, profileData } from '$lib/auth'
import { getGroups, type Action, type Group } from './actions'
import { themeData } from '$lib/ui/colors'
+ import { page } from '$app/stores'
export let open = false
$: if (open) search = ''
@@ -20,7 +21,8 @@
$resumables,
$profile,
$profileData.profiles,
- $themeData
+ $themeData,
+ $page.data.contextual?.actions
)
let search = ''
diff --git a/src/lib/components/ui/navbar/commands/actions.ts b/src/lib/components/ui/navbar/commands/actions.ts
index 980e9f6e..d47151fe 100644
--- a/src/lib/components/ui/navbar/commands/actions.ts
+++ b/src/lib/components/ui/navbar/commands/actions.ts
@@ -43,6 +43,7 @@ import {
ChatBubbleOvalLeftEllipsis,
ChatBubbleLeftRight,
Swatch,
+ Plus,
} from 'svelte-hero-icons'
import { get } from 'svelte/store'
@@ -66,7 +67,8 @@ export function getGroups(
resumables: ResumableItem[],
profile: Profile,
profiles: Profile[],
- td: ThemeData
+ td: ThemeData,
+ contextual?: Action[]
) {
return [
{
@@ -77,6 +79,10 @@ export function getGroups(
href: r.url,
})),
},
+ {
+ name: t.get('nav.commands.contextual'),
+ actions: contextual ?? [],
+ },
{
name: t.get('nav.commands.main'),
actions: [
@@ -254,6 +260,26 @@ export function getGroups(
name: t.get('account.accounts'),
icon: UserGroup,
},
+ {
+ href: '/login',
+ name: t.get('account.login'),
+ icon: ArrowRightOnRectangle,
+ },
+ {
+ href: '/signup',
+ name: t.get('account.signup'),
+ icon: Identification,
+ },
+ {
+ href: '/login/guest',
+ name: t.get('account.addGuest'),
+ icon: Plus,
+ },
+ {
+ href: '/accounts',
+ name: t.get('account.accounts'),
+ icon: UserGroup,
+ },
]
: [
{
@@ -266,6 +292,11 @@ export function getGroups(
name: t.get('account.signup'),
icon: Identification,
},
+ {
+ href: '/login/guest',
+ name: t.get('account.addGuest'),
+ icon: Plus,
+ },
{
href: '/accounts',
name: t.get('account.accounts'),
diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json
index c89d8fa2..6c76f2df 100644
--- a/src/lib/i18n/en.json
+++ b/src/lib/i18n/en.json
@@ -46,7 +46,8 @@
"feeds": "Feeds",
"downloading": "Downloading actions",
"setTheme": "Set theme",
- "setThemeTo": "Set theme to {{default}}"
+ "setThemeTo": "Set theme to {{default}}",
+ "contextual": "On this page"
}
},
"account": {
diff --git a/src/routes/+page.ts b/src/routes/+page.ts
index d7c36589..51ef45cc 100644
--- a/src/routes/+page.ts
+++ b/src/routes/+page.ts
@@ -6,6 +6,8 @@ import { error } from '@sveltejs/kit'
import { browser } from '$app/environment'
import { instance } from '$lib/instance'
import { postFeed, postFeeds, shouldReload } from '$lib/lemmy/postfeed.js'
+import { t } from '$lib/translations.js'
+import { ChevronDoubleUp } from 'svelte-hero-icons'
export async function load({ url, fetch }) {
const cursor = url.searchParams.get('cursor') as string | undefined
@@ -18,16 +20,27 @@ export async function load({ url, fetch }) {
const listingType: ListingType =
(url.searchParams.get('type') as ListingType) || settings.defaultSort.feed
- return await postFeed({
- id: 'main',
- request: {
- page_cursor: cursor,
- sort: sort,
- type_: listingType,
- limit: 20,
- show_hidden: settings.posts.showHidden,
+ return {
+ ...(await postFeed({
+ id: 'main',
+ request: {
+ page_cursor: cursor,
+ sort: sort,
+ type_: listingType,
+ limit: 20,
+ show_hidden: settings.posts.showHidden,
+ },
+ url: url,
+ fetch: fetch,
+ })),
+ contextual: {
+ actions: [
+ {
+ name: t.get('routes.post.scrollToTop'),
+ handle: () => window?.scrollTo({ top: 0, behavior: 'instant' }),
+ icon: ChevronDoubleUp,
+ },
+ ],
},
- url: url,
- fetch: fetch,
- })
+ }
}
diff --git a/src/routes/post/[instance]/[id=integer]/+page.svelte b/src/routes/post/[instance]/[id=integer]/+page.svelte
index 3374a6ca..81b8c861 100644
--- a/src/routes/post/[instance]/[id=integer]/+page.svelte
+++ b/src/routes/post/[instance]/[id=integer]/+page.svelte
@@ -1,7 +1,7 @@
-