mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-18 03:55:30 -04:00
(ts) migrate remaining .js files in ~/src to typescript
This commit is contained in:
parent
4edd90af7d
commit
374f8b8120
@ -40,8 +40,8 @@
|
|||||||
import { mapState } from 'pinia';
|
import { mapState } from 'pinia';
|
||||||
|
|
||||||
import useConfig from '../composables/useConfig.ts';
|
import useConfig from '../composables/useConfig.ts';
|
||||||
import adPlaceholders from '../src/adPlaceholders.js';
|
import adPlaceholders from '../src/adPlaceholders.ts';
|
||||||
import getAdsInternal from '../src/adsInternal.js';
|
import getAdsInternal from '../src/adsInternal.ts';
|
||||||
import { randomItemWeighted } from '../src/helpers.ts';
|
import { randomItemWeighted } from '../src/helpers.ts';
|
||||||
import { useMainStore } from '../store/index.ts';
|
import { useMainStore } from '../store/index.ts';
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import useConfig from '../composables/useConfig.ts';
|
import useConfig from '../composables/useConfig.ts';
|
||||||
import { socialLinks } from '../src/contact.js';
|
import { socialLinks } from '../src/contact.ts';
|
||||||
import { clearUrl } from '../src/helpers.ts';
|
import { clearUrl } from '../src/helpers.ts';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -194,7 +194,7 @@ import { useFetch } from 'nuxt/app';
|
|||||||
|
|
||||||
import useConfig from '../composables/useConfig.ts';
|
import useConfig from '../composables/useConfig.ts';
|
||||||
import useDialogue from '../composables/useDialogue.ts';
|
import useDialogue from '../composables/useDialogue.ts';
|
||||||
import { getContactLinks, getSocialLinks, getSupportLinks } from '../src/contact.js';
|
import { getContactLinks, getSocialLinks, getSupportLinks } from '../src/contact.ts';
|
||||||
import { sessionCookieSetting } from '../src/cookieSettings.ts';
|
import { sessionCookieSetting } from '../src/cookieSettings.ts';
|
||||||
import { groupBy } from '../src/helpers.ts';
|
import { groupBy } from '../src/helpers.ts';
|
||||||
import { useMainStore } from '../store/index.ts';
|
import { useMainStore } from '../store/index.ts';
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import ClipboardJS from 'clipboard';
|
import ClipboardJS from 'clipboard';
|
||||||
|
|
||||||
import { COLOURS } from '../src/contact.js';
|
import { COLOURS } from '../src/contact.ts';
|
||||||
|
|
||||||
// adapted from https://shareon.js.org (MIT)
|
// adapted from https://shareon.js.org (MIT)
|
||||||
// can't use from yarn, because window.onload conflicts with SSR
|
// can't use from yarn, because window.onload conflicts with SSR
|
||||||
|
@ -21,18 +21,15 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
|
|
||||||
import useConfig from '../composables/useConfig.ts';
|
import useConfig from '../composables/useConfig.ts';
|
||||||
import { getSocialLinks } from '../src/contact.js';
|
import { getSocialLinks } from '../src/contact.ts';
|
||||||
import { groupBy } from '../src/helpers.ts';
|
import { groupBy } from '../src/helpers.ts';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
setup() {
|
setup() {
|
||||||
|
const config = useConfig();
|
||||||
return {
|
return {
|
||||||
config: useConfig(),
|
config,
|
||||||
};
|
socials: groupBy([...getSocialLinks(config)], (l) => l.group),
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
socials: groupBy([...getSocialLinks(this.config)], (l) => l.group),
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getSupportLinks } from '../src/contact.js';
|
import { getSupportLinks } from '../src/contact.ts';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
@ -151,7 +151,7 @@ import { useNuxtApp } from 'nuxt/app';
|
|||||||
|
|
||||||
import useDialogue from '~/composables/useDialogue.ts';
|
import useDialogue from '~/composables/useDialogue.ts';
|
||||||
import useSimpleHead from '~/composables/useSimpleHead.ts';
|
import useSimpleHead from '~/composables/useSimpleHead.ts';
|
||||||
import { min, max, closed, MONTHS, AREAS, TRANSFER_METHODS } from '~/src/timesheets.js';
|
import { min, max, closed, MONTHS, AREAS, TRANSFER_METHODS } from '~/src/timesheets.ts';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async setup() {
|
async setup() {
|
||||||
|
@ -108,7 +108,7 @@ import { DateTime } from 'luxon';
|
|||||||
import { useNuxtApp } from 'nuxt/app';
|
import { useNuxtApp } from 'nuxt/app';
|
||||||
|
|
||||||
import useSimpleHead from '~/composables/useSimpleHead.ts';
|
import useSimpleHead from '~/composables/useSimpleHead.ts';
|
||||||
import { min, max, MONTHS, PERIODS } from '~/src/timesheets.js';
|
import { min, max, MONTHS, PERIODS } from '~/src/timesheets.ts';
|
||||||
|
|
||||||
function* range(start, end) {
|
function* range(start, end) {
|
||||||
for (let i = start; i <= end; i++) {
|
for (let i = start; i <= end; i++) {
|
||||||
|
@ -98,7 +98,7 @@ import { defineComponent } from 'vue';
|
|||||||
|
|
||||||
import useConfig from '../composables/useConfig.ts';
|
import useConfig from '../composables/useConfig.ts';
|
||||||
import useSimpleHead from '../composables/useSimpleHead.ts';
|
import useSimpleHead from '../composables/useSimpleHead.ts';
|
||||||
import { getContactLinks, getSocialLinks } from '../src/contact.js';
|
import { getContactLinks, getSocialLinks } from '../src/contact.ts';
|
||||||
import { groupBy } from '../src/helpers.ts';
|
import { groupBy } from '../src/helpers.ts';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
@ -111,14 +111,12 @@ export default defineComponent({
|
|||||||
useSimpleHead({
|
useSimpleHead({
|
||||||
title: translator.translate('contact.header'),
|
title: translator.translate('contact.header'),
|
||||||
}, translator);
|
}, translator);
|
||||||
|
|
||||||
|
const config = useConfig();
|
||||||
return {
|
return {
|
||||||
config: useConfig(),
|
config,
|
||||||
};
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
links: groupBy(
|
links: groupBy(
|
||||||
[...getContactLinks(this.config, this.$translator), ...getSocialLinks(this.config)],
|
[...getContactLinks(config, translator), ...getSocialLinks(config)],
|
||||||
(l) => l.group,
|
(l) => l.group,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,14 @@
|
|||||||
export const adsInternal = [
|
interface Ad {
|
||||||
|
enabled: boolean;
|
||||||
|
locale: string;
|
||||||
|
image: string;
|
||||||
|
placeholders: string[];
|
||||||
|
link: string;
|
||||||
|
display: string;
|
||||||
|
alt: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const adsInternal: Ad[] = [
|
||||||
{
|
{
|
||||||
enabled: false,
|
enabled: false,
|
||||||
locale: 'en',
|
locale: 'en',
|
||||||
@ -72,8 +82,8 @@ export const adsInternal = [
|
|||||||
// },
|
// },
|
||||||
];
|
];
|
||||||
|
|
||||||
export default (locale) => {
|
export default (locale: string): Record<string, (Ad & { chance: number })[]> => {
|
||||||
const adsInternalPerPlaceholder = {};
|
const adsInternalPerPlaceholder: Record<string, (Ad & { chance: number })[]> = {};
|
||||||
for (const ad of adsInternal) {
|
for (const ad of adsInternal) {
|
||||||
const rightLocale = ad.locale === null || ad.locale === locale;
|
const rightLocale = ad.locale === null || ad.locale === locale;
|
||||||
if (ad.enabled === false || !rightLocale) {
|
if (ad.enabled === false || !rightLocale) {
|
@ -1,4 +1,16 @@
|
|||||||
export const contact = {
|
import type { Config, Link } from '~/locale/config.ts';
|
||||||
|
import type { Translator } from '~/src/translator.ts';
|
||||||
|
|
||||||
|
interface ContactLink extends Link {
|
||||||
|
group: string;
|
||||||
|
colour: string;
|
||||||
|
avatar?: string | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
type Group = 'all' | 'calendar' | 'polish' | 'shop';
|
||||||
|
type GroupedLinks = Partial<Record<Group, Record<string, Link>>>;
|
||||||
|
|
||||||
|
export const contact: GroupedLinks = {
|
||||||
all: {
|
all: {
|
||||||
discord_community: {
|
discord_community: {
|
||||||
icon: 'b:discord',
|
icon: 'b:discord',
|
||||||
@ -40,7 +52,7 @@ export const contact = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const socialLinks = {
|
export const socialLinks: GroupedLinks = {
|
||||||
all: {
|
all: {
|
||||||
mastodon: {
|
mastodon: {
|
||||||
icon: 'mastodon',
|
icon: 'mastodon',
|
||||||
@ -50,7 +62,6 @@ export const socialLinks = {
|
|||||||
},
|
},
|
||||||
bluesky: {
|
bluesky: {
|
||||||
icon: 'bluesky',
|
icon: 'bluesky',
|
||||||
iconSet: '',
|
|
||||||
url: 'https://bsky.app/profile/pronouns.page',
|
url: 'https://bsky.app/profile/pronouns.page',
|
||||||
headline: 'pronouns.page',
|
headline: 'pronouns.page',
|
||||||
},
|
},
|
||||||
@ -71,7 +82,6 @@ export const socialLinks = {
|
|||||||
},
|
},
|
||||||
bluesky: {
|
bluesky: {
|
||||||
icon: 'bluesky',
|
icon: 'bluesky',
|
||||||
iconSet: '',
|
|
||||||
url: 'https://bsky.app/profile/zaimki.pl',
|
url: 'https://bsky.app/profile/zaimki.pl',
|
||||||
headline: 'zaimki.pl',
|
headline: 'zaimki.pl',
|
||||||
},
|
},
|
||||||
@ -110,7 +120,6 @@ export const socialLinks = {
|
|||||||
},
|
},
|
||||||
bluesky: {
|
bluesky: {
|
||||||
icon: 'bluesky',
|
icon: 'bluesky',
|
||||||
iconSet: '',
|
|
||||||
url: 'https://bsky.app/profile/calendar.pronouns.page',
|
url: 'https://bsky.app/profile/calendar.pronouns.page',
|
||||||
headline: 'calendar.pronouns.page',
|
headline: 'calendar.pronouns.page',
|
||||||
},
|
},
|
||||||
@ -131,7 +140,7 @@ export const socialLinks = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const COLOURS = {
|
export const COLOURS: Record<string, string> = {
|
||||||
mastodon: '#3188d4',
|
mastodon: '#3188d4',
|
||||||
facebook: '#1877F2',
|
facebook: '#1877F2',
|
||||||
linkedin: '#2867B2',
|
linkedin: '#2867B2',
|
||||||
@ -152,13 +161,13 @@ export const COLOURS = {
|
|||||||
workshops: '#C71585',
|
workshops: '#C71585',
|
||||||
};
|
};
|
||||||
|
|
||||||
const AVATARS = {
|
const AVATARS: Partial<Record<Group, string>> = {
|
||||||
all: 'pronounspage.png',
|
all: 'pronounspage.png',
|
||||||
polish: 'neutratywy.png',
|
polish: 'neutratywy.png',
|
||||||
calendar: 'calendarqueer.png',
|
calendar: 'calendarqueer.png',
|
||||||
};
|
};
|
||||||
|
|
||||||
const supportLinks = (translator) => {
|
const supportLinks = (translator: Translator): GroupedLinks => {
|
||||||
return {
|
return {
|
||||||
all: {
|
all: {
|
||||||
bank: {
|
bank: {
|
||||||
@ -182,15 +191,12 @@ const supportLinks = (translator) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
function* getLink(links, group) {
|
function* getLink(links: GroupedLinks, group: Group): Generator<ContactLink> {
|
||||||
const featureLinks = links[group] || {};
|
const featureLinks = links[group] || {};
|
||||||
for (const key in featureLinks) {
|
for (const [key, link] of Object.entries(featureLinks)) {
|
||||||
if (!featureLinks.hasOwnProperty(key)) {
|
let avatar: string | undefined = AVATARS[group];
|
||||||
continue;
|
if (link.url?.startsWith('mailto:')) {
|
||||||
}
|
avatar = undefined;
|
||||||
let avatar = AVATARS[group];
|
|
||||||
if (featureLinks[key].url.startsWith('mailto:')) {
|
|
||||||
avatar = null;
|
|
||||||
}
|
}
|
||||||
yield {
|
yield {
|
||||||
...featureLinks[key],
|
...featureLinks[key],
|
||||||
@ -201,7 +207,7 @@ function* getLink(links, group) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function* getContactLinks(config, translator) {
|
export function* getContactLinks(config: Config, translator: Translator): Generator<ContactLink> {
|
||||||
if (config.faq.enabled) {
|
if (config.faq.enabled) {
|
||||||
yield {
|
yield {
|
||||||
url: `/${config.faq.route}`,
|
url: `/${config.faq.route}`,
|
||||||
@ -226,7 +232,7 @@ export function* getContactLinks(config, translator) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function* getSocialLinks(config) {
|
export function* getSocialLinks(config: Config) {
|
||||||
yield * getLink(socialLinks, 'all');
|
yield * getLink(socialLinks, 'all');
|
||||||
if (config.locale === 'pl') {
|
if (config.locale === 'pl') {
|
||||||
yield * getLink(socialLinks, 'polish');
|
yield * getLink(socialLinks, 'polish');
|
||||||
@ -237,6 +243,6 @@ export function* getSocialLinks(config) {
|
|||||||
yield * getLink(socialLinks, 'shop');
|
yield * getLink(socialLinks, 'shop');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function* getSupportLinks(translator) {
|
export function* getSupportLinks(translator: Translator) {
|
||||||
yield * getLink(supportLinks(translator), 'all');
|
yield * getLink(supportLinks(translator), 'all');
|
||||||
}
|
}
|
@ -26,7 +26,7 @@ export const AREAS = [
|
|||||||
'documentation',
|
'documentation',
|
||||||
'community',
|
'community',
|
||||||
'other',
|
'other',
|
||||||
];
|
] as const;
|
||||||
|
|
||||||
export const MONTHS = {
|
export const MONTHS = {
|
||||||
1: 'Jan',
|
1: 'Jan',
|
Loading…
x
Reference in New Issue
Block a user