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

Refactor pagination, optimize seo #1523

Merged
merged 4 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 7 additions & 3 deletions frontend/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const getPath = (path: string) => {
const langRefs = locales.value.map((it) => ({
rel: 'alternate',
hreflang: it.code,
href: `${config.public.domain}/${it.code}${getPath(route.path)}`
href: `https://${config.public.domain}/${it.code}${getPath(route.path)}`
}));
useHead({
link: [
Expand All @@ -44,17 +44,21 @@ useHead({
},
{
rel: 'canonical',
href: `${config.public.domain}/${locale.value}${getPath(route.path)}`
href: `https://${config.public.domain}/${locale.value}${getPath(route.path)}`
},
{
rel: 'alternate',
hreflang: 'x-default',
href: `${config.public.domain}/ru${getPath(route.path)}`
href: `https://${config.public.domain}/ru${getPath(route.path)}`
},
...langRefs
],
title: `${t('meta.default_title.first')} | ${t('meta.default_title.second')}`,
meta: [
{
name: 'keywords',
content: t('meta.default_keywords')
},
{
name: 'description',
content: t('meta.default_description')
Expand Down
17 changes: 16 additions & 1 deletion frontend/components/search/Pagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { countries as supportedCountries } from '../../../common/const/supportedCountries';
import { useRoute } from 'vue-router';

const { t, locale } = useI18n();

Check warning on line 5 in frontend/components/search/Pagination.vue

View workflow job for this annotation

GitHub Actions / Check code syntax

't' is assigned a value but never used

interface ResponsiveDevice {
value: boolean;
Expand Down Expand Up @@ -38,7 +38,7 @@

const {
data: posterEvents,
error: errorEvents,

Check warning on line 41 in frontend/components/search/Pagination.vue

View workflow job for this annotation

GitHub Actions / Check code syntax

'errorEvents' is assigned a value but never used
pending
} = await apiRouter.filters.findEventsPagination.useQuery({
data: {
Expand All @@ -55,6 +55,14 @@
}
});

useHead({
script: [
posterEvents.value
? getJSONEventList(posterEvents.value.docs, locale.value, route.path)
: undefined
]
});

watch(
() => route.query,
(value) => {
Expand All @@ -77,7 +85,6 @@
watch(
() => posterEvents,
(posterEvents) => {
console.log(posterEvents);
if (posterEvents.value.page > posterEvents.value.totalPages) {
const currentParams = { ...route.query, ...{ page: 1 } };
navigateTo({ query: currentParams });
Expand Down Expand Up @@ -188,6 +195,14 @@
/>
</NuxtLink>
</div>
<SearchLoader
v-if="pending"
:size="mobile ? 'middle' : 'big'"
/>
<SearchNotFound
v-if="!pending && (!posterEvents || posterEvents.docs.length === 0)"
:title="$t('event.filteredEvents.no_events_found')"
/>
<SearchEventCardsList
v-if="posterEvents.docs && posterEvents.docs.length !== 0"
:events="posterEvents.docs"
Expand Down
29 changes: 29 additions & 0 deletions frontend/components/search/PaginationCity.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { countries as supportedCountries } from '../../../common/const/supportedCountries';
import { useRoute } from 'vue-router';
import { CommonErrorsEnum } from '../../../common/const';

const { t, locale } = useI18n();

Expand Down Expand Up @@ -78,6 +79,26 @@ const {
}
});

if (errorEvents.value) {
if (
errorEvents.value.data &&
errorEvents.value.data.message === CommonErrorsEnum.CITY_NOT_FOUND
) {
throw createError({
statusCode: 404,
data: { message: t(`errors.${CommonErrorsEnum.CITY_NOT_FOUND}`, { city: city }) }
});
}
}

useHead({
script: [
posterEvents.value
? getJSONEventList(posterEvents.value.docs, locale.value, route.path)
: undefined
]
});

watch(
() => route.query,
(value) => {
Expand Down Expand Up @@ -201,6 +222,14 @@ watch(
/>
</NuxtLink>
</div>
<SearchLoader
v-if="pending"
:size="mobile ? 'middle' : 'big'"
/>
<SearchNotFound
v-if="!pending && !posterEvents"
:title="$t('event.filteredEvents.no_events_found')"
/>
<SearchEventCardsList
v-if="posterEvents.docs && posterEvents.docs.length !== 0"
:events="posterEvents.docs"
Expand Down
38 changes: 32 additions & 6 deletions frontend/components/search/PaginationCountry.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<script setup lang="ts">
import {
declinationCountries,
countries as supportedCountries,
queryToCountryLocaleName,
queryToCountryCode
} from '../../../common/const/supportedCountries';
import { queryToCountryLocaleName } from '../../../common/const/supportedCountries';
import { useRoute } from 'vue-router';
import { CommonErrorsEnum } from '../../../common/const';

const { t, locale } = useI18n();

Expand Down Expand Up @@ -62,6 +58,28 @@ const {
}
});

if (errorEvents.value) {
if (
errorEvents.value.data &&
errorEvents.value.data.message === CommonErrorsEnum.COUNTRY_NOT_FOUND
) {
throw createError({
statusCode: 404,
data: {
message: t(`errors.${CommonErrorsEnum.COUNTRY_NOT_FOUND}`, { country: country })
}
});
}
}

useHead({
script: [
posterEvents.value
? getJSONEventList(posterEvents.value.docs, locale.value, route.path)
: undefined
]
});

watch(
() => route.query,
(value) => {
Expand Down Expand Up @@ -185,6 +203,14 @@ watch(
/>
</NuxtLink>
</div>
<SearchLoader
v-if="pending"
:size="mobile ? 'middle' : 'big'"
/>
<SearchNotFound
v-if="!pending && !posterEvents"
:title="$t('event.filteredEvents.no_events_found')"
/>
<SearchEventCardsList
v-if="posterEvents.docs && posterEvents.docs.length !== 0"
:events="posterEvents.docs"
Expand Down
2 changes: 2 additions & 0 deletions frontend/i18n/locales/en-GB/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export default {
first: 'Events Serbia ',
second: 'Events Montenegro - Peredelano Afisha'
},
default_keywords:
'best events in Serbia, best events in Montenegro, Belgrade, Cetinje, great variety of events, event poster 2025, schedule, tickets, events, exhibitions, excursions, shows, concerts, rock concerts, festivals, performances, flash mobs, parties, children, scheme, address, photos',
default_description:
'The catalog features dozens of events in Serbia, Montenegro across various categories: concerts, meetings, exhibitions, festivals, masterclasses',
about_us: {
Expand Down
5 changes: 3 additions & 2 deletions frontend/i18n/locales/ru-RU/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ export default {
site_name: 'Афиша Peredelano',
default_title: {
first: 'Афиша мероприятий Сербии',
second: 'Афиша мероприятий Черногории - Peredelano Afisha'
second: 'Афиша мероприятий Черногории - Афиша Переделано'
},

default_keywords:
'лучшие мероприятия Сербии, лучшие мероприятия Черногории, Белград, Цетине, огромный выбор мероприятий, афиша событий 2025, расписание, билеты, мероприятия, выставки, экскурсии, шоу, концерты, рок-концерты, фестивали, спектакли, флешмобы, вечеринки, детям, схема, адрес, фото',
default_description:
'В каталоге представлены десятки мероприятий Сербии, Черногории по различным направлениям: концерты, встречи, выставки, фестивали, мастер-классы',
about_us: {
Expand Down
58 changes: 4 additions & 54 deletions frontend/pages/city/[city].vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<script setup lang="ts">
import { useUserStore } from '../../stores/user.store';
import {
declinationCountries,
countries as supportedCountries
} from '../../../common/const/supportedCountries';

const route = useRoute();

const userStore = useUserStore();

const { locale, t } = useI18n();
const mobile = inject('mobile');

Check warning on line 13 in frontend/pages/city/[city].vue

View workflow job for this annotation

GitHub Actions / Check code syntax

'mobile' is assigned a value but never used
import { CommonErrorsEnum } from '../../../common/const/common-errors';
import {
declinationCountries,
countries as supportedCountries
} from '../../../common/const/supportedCountries';

const { sendAnalytics } = useSendTrackingEvent();

Expand Down Expand Up @@ -50,44 +49,11 @@
})
});

const dateStart = computed(() =>
dateFromQueryToFilter('first', getFirstQuery(route.query.startDate as string))
);
const dateEnd = computed(() => {
return dateFromQueryToFilter('second', getFirstQuery(route.query.endDate as string));
});
const tags = computed(() =>

Check warning on line 52 in frontend/pages/city/[city].vue

View workflow job for this annotation

GitHub Actions / Check code syntax

'tags' is assigned a value but never used
getFirstQuery(route.query.tags)
.split(', ')
.filter((item) => item !== '')
);
const {
data: posterEvents,
error: errorEvents,
pending
} = await apiRouter.filters.findEventsByCity.useQuery({
data: {
city,
query: {
tags,
startDate: dateStart,
endDate: dateEnd
},
watch: [tags.value, dateStart.value, dateEnd.value]
}
});

if (errorEvents.value) {
if (
errorEvents.value.data &&
errorEvents.value.data.message === CommonErrorsEnum.CITY_NOT_FOUND
) {
throw createError({
statusCode: 404,
data: { message: t(`errors.${CommonErrorsEnum.CITY_NOT_FOUND}`, { city: city }) }
});
}
}

export type Option = { label: string; value: string };

Expand Down Expand Up @@ -118,14 +84,6 @@
return filtered;
});

useHead({
script: [
posterEvents.value
? getJSONEventList(posterEvents.value, locale.value, route.path)
: undefined
]
});

watch(
() => route.query,
(value) => {
Expand All @@ -152,14 +110,6 @@
</FiltersHeroWrap>

<SearchCardsWrapper>
<SearchLoader
v-if="pending"
:size="mobile ? 'middle' : 'big'"
/>
<SearchNotFound
v-if="!pending && !posterEvents"
:title="$t('event.filteredEvents.no_events_found')"
/>
<!-- <SearchEventCardsList-->
<!-- v-if="posterEvents && posterEvents.length !== 0"-->
<!-- :events="posterEvents"-->
Expand Down
Loading
Loading