Skip to content

Commit

Permalink
feat: login url helper
Browse files Browse the repository at this point in the history
  • Loading branch information
veryCrunchy committed Apr 8, 2024
1 parent f95c22c commit 66e8ed0
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions plugins/content.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
export default defineNuxtPlugin(() => {
const config = useRuntimeConfig().public;
const img = useImage();
const route = useRoute();

return {
provide: {
ogTitle: (title?: string) => `GreasyGang ${title ? " - " + title : ""}`,
login: (scopes?: Scopes[], redirect: boolean = true) => {
const loginURL = new URL(config.apiBase + "/login/twitch");
if (redirect) loginURL.searchParams.set("redirect", route.fullPath);
if (scopes) loginURL.searchParams.set("scopes", scopes.join(" "));

return loginURL;
},
ContentImage: (path: string) =>
`${config.apiBase}/image/${config.branch}/website/images/${path}`,
PreContentImage: (path: string, width?: number, height?: number) => {
Expand Down Expand Up @@ -37,3 +45,67 @@ export default defineNuxtPlugin(() => {
},
};
});

type Scopes =
| "analytics:read:extensions"
| "analytics:read:games"
| "bits:read"
| "channel:manage:ads"
| "channel:read:ads"
| "channel:manage:broadcast"
| "channel:read:charity"
| "channel:edit:commercial"
| "channel:read:editors"
| "channel:manage:extensions"
| "channel:read:goals"
| "channel:read:guest_star"
| "channel:manage:guest_star"
| "channel:read:hype_train"
| "channel:manage:moderators"
| "channel:read:polls"
| "channel:manage:polls"
| "channel:read:predictions"
| "channel:manage:predictions"
| "channel:manage:raids"
| "channel:read:redemptions"
| "channel:manage:redemptions"
| "channel:manage:schedule"
| "channel:read:stream_key"
| "channel:read:subscriptions"
| "channel:manage:videos"
| "channel:read:vips"
| "channel:manage:vips"
| "clips:edit"
| "moderation:read"
| "moderator:manage:announcements"
| "moderator:manage:automod"
| "moderator:read:automod_settings"
| "moderator:manage:automod_settings"
| "moderator:manage:banned_users"
| "moderator:read:blocked_terms"
| "moderator:manage:blocked_terms"
| "moderator:manage:chat_messages"
| "moderator:read:chat_settings"
| "moderator:manage:chat_settings"
| "moderator:read:chatters"
| "moderator:read:followers"
| "moderator:read:guest_star"
| "moderator:manage:guest_star"
| "moderator:read:shield_mode"
| "moderator:manage:shield_mode"
| "moderator:read:shoutouts"
| "moderator:manage:shoutouts"
| "moderator:read:unban_requests"
| "moderator:manage:unban_requests"
| "user:edit"
| "user:edit:follows"
| "user:read:blocked_users"
| "user:manage:blocked_users"
| "user:read:broadcast"
| "user:manage:chat_color"
| "user:read:email"
| "user:read:emotes"
| "user:read:follows"
| "user:read:moderated_channels"
| "user:read:subscriptions"
| "user:manage:whispers";

0 comments on commit 66e8ed0

Please sign in to comment.