Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Directus SDK #578

Merged
merged 4 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<img
v-if="update.image"
class="c-national-team-competition-update__image"
:alt="update.image.description"
:alt="update.image.description || undefined"
:src="imageFallbackSrc"
:srcset="imageSrcSet"
sizes="(min-width: 800px}) 800px, 96vw"
Expand Down
10 changes: 5 additions & 5 deletions components/national-teams/st-national-teams.prop.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PartialItem } from '@directus/sdk';
import { type DirectusFile } from '@directus/sdk';
import { Gender, Role } from '~/plugins/cms-service';
import { DirectusImage, DirectusPerson } from '~/plugins/directus';
import { DirectusPerson, DirectusSchema } from '~/plugins/directus';

export interface Player {
id: number;
Expand Down Expand Up @@ -41,7 +41,7 @@ export interface NationalTeamCompetition {
export interface NationalTeamCompetitionUpdate {
id: number;
body: string;
image?: DirectusImage;
image?: DirectusFile<DirectusSchema>;
is_key: boolean;
teams: { id: number; name: string }[];
date_created: string;
Expand All @@ -57,7 +57,7 @@ export interface NationalTeam {
name: string;
slug: string;
gender: string;
team_photo?: DirectusImage;
team_photo?: DirectusFile<DirectusSchema>;
team_photo_vertical_shift?: number;
players: Player[];
/**
Expand All @@ -75,7 +75,7 @@ export interface NationalTeamForCompetition {
competition: NationalTeamCompetition;
team: Pick<NationalTeam, 'name' | 'slug'>;
players: Player[];
coaches: PartialItem<DirectusPerson>[];
coaches: DirectusPerson[];
}

// Just to clear a Nuxt warning.
Expand Down
1 change: 1 addition & 0 deletions components/resources/st-resource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default defineComponent({
if (!this.resource?.file) {
return;
}
// @ts-ignore TODO: Check the actual type
return humanFileSize(this.resource.file.filesize, 2, this.$i18n.locale);
},
fileName(): string {
Expand Down
3 changes: 1 addition & 2 deletions components/st-club-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
</template>

<script lang="ts">
import { PartialItem } from '@directus/sdk';
import { defineComponent, PropType } from 'vue';
import { DirectusClub, getAssetURL } from '~/plugins/directus';

export default defineComponent({
props: {
clubs: {
type: Array as PropType<PartialItem<DirectusClub>[]>,
type: Array as PropType<DirectusClub[]>,
required: true,
},
},
Expand Down
2 changes: 1 addition & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const config: NuxtConfig = {

// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
transpile: ['vue-tooltip'],
transpile: ['vue-tooltip', '@directus/sdk', '@directus/system-data'],
postcss: {
postcssOptions: {
plugins: {
Expand Down
51 changes: 26 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"engines": {
"node": "20"
},
"type": "commonjs",
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
Expand All @@ -20,7 +21,7 @@
"*.{css,vue}": "stylelint"
},
"dependencies": {
"@directus/sdk": "^9.14.2",
"@directus/sdk": "^15.0.3",
"@fortawesome/free-brands-svg-icons": "^6.5.1",
"@fortawesome/free-solid-svg-icons": "^6.5.1",
"@hcaptcha/vue-hcaptcha": "^1.3.0",
Expand Down
7 changes: 6 additions & 1 deletion pages/_.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ export default defineComponent({
// but with the path in another language.
// This can notably happen when using the language switcher.
// We just redirect to fix the path.
redirect(`/${i18n.locale}${page.path}`);
let pathLocale = `/${i18n.locale}`;
// The current strategy doesn't put a prefix for the default language
if (i18n.locale === i18n.defaultLocale) {
pathLocale = '';
}
redirect(`${pathLocale}${page.path}`);
}

return {
Expand Down
3 changes: 1 addition & 2 deletions pages/clubs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
</template>

<script lang="ts">
import { PartialItem } from '@directus/sdk';
import { defineComponent } from 'vue';
import stClubList from '~/components/st-club-list.vue';
import { DirectusClub } from '~/plugins/directus';
Expand All @@ -20,7 +19,7 @@ export default defineComponent({
components: { stClubList },
data() {
return {
clubs: [] as PartialItem<DirectusClub>[],
clubs: [] as DirectusClub[],
};
},
nuxtI18n: {
Expand Down
2 changes: 1 addition & 1 deletion pages/national-teams/_team.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
v-if="team.team_photo"
class="c-team__photo"
:style="`object-position: 0 ${teamPhotoVerticalShiftInPercentage}%;`"
:alt="team.team_photo.description"
:alt="team.team_photo.description || undefined"
:src="mainImageFallbackSrc"
:srcset="mainImageSrcSet"
:sizes="imgTagSizes"
Expand Down
5 changes: 4 additions & 1 deletion pages/news/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import stLoader from '~/components/st-loader.vue';
import stNewsList from '~/components/news/st-news-list.vue';
import { NewsEntry } from '~/components/news/st-news';
import StPagination from '~/components/st-pagination.vue';
import { DirectusDomain } from '~/plugins/directus';

export default defineComponent({
components: { stLoader, stNewsList, StPagination },
Expand Down Expand Up @@ -83,7 +84,9 @@ export default defineComponent({
if (!this.filteredDomainId) {
return;
}
return this.$store.getters.getDomainById(this.filteredDomainId);
const domain: DirectusDomain = this.$store.getters.getDomainById(this.filteredDomainId);

return domain.name;
},
},
watch: {
Expand Down
3 changes: 1 addition & 2 deletions pages/regional-associations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
</template>

<script lang="ts">
import { PartialItem } from '@directus/sdk';
import { defineComponent } from 'vue';
import stClubList from '~/components/st-club-list.vue';
import { DirectusClub } from '~/plugins/directus';
Expand All @@ -18,7 +17,7 @@ export default defineComponent({
components: { stClubList },
data() {
return {
associations: [] as PartialItem<DirectusClub>[],
associations: [] as DirectusClub[],
};
},
nuxtI18n: {
Expand Down
Loading
Loading