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

HOTFIX: Fix ld-json #1414

Merged
merged 4 commits into from
Oct 5, 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
9 changes: 1 addition & 8 deletions frontend/components/detailes/Image.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup>
import { SeoItempropGlobalEnum } from '../../constants/enums/seo';

defineProps({
imageUrl: {
type: String,
Expand All @@ -13,18 +11,14 @@ defineProps({
});
</script>
<template>
<div
class="event-image event-image__container"
:itemprop="SeoItempropGlobalEnum.IMAGE"
>
<div class="event-image event-image__container">
<img
v-if="imageUrl"
class="event-image__image"
:src="imageUrl"
width="350"
height="250"
:alt="altContent"
:itemprop="SeoItempropGlobalEnum.IMAGE"
/>
<img
v-else
Expand All @@ -33,7 +27,6 @@ defineProps({
width="350"
height="250"
alt=""
:itemprop="SeoItempropGlobalEnum.IMAGE"
/>
</div>
</template>
Expand Down
3 changes: 0 additions & 3 deletions frontend/components/detailes/Info.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script setup lang="ts">
import type { PropType } from 'vue';
import type { EventOnPoster } from '../../../common/types';
import { SeoItempropEventEnum } from '../../constants/enums/seo';
import { PEREDELANO_CREATOR_ID } from '../../../common/const/eventTypes';

const mobile = inject<boolean>('mobile');
Expand Down Expand Up @@ -61,14 +60,12 @@ defineProps({
<p
v-if="posterEvent.creatorId !== PEREDELANO_CREATOR_ID"
class="event-summary__description text3"
:itemprop="SeoItempropEventEnum.DESCRIPTION"
>
{{ posterEvent.description }}
</p>
<div
v-if="posterEvent.creatorId === PEREDELANO_CREATOR_ID"
class="event-summary__html-description"
:itemprop="SeoItempropEventEnum.DESCRIPTION"
v-html="useSanitizer(posterEvent.description)"
/>
<CommonButton
Expand Down
3 changes: 0 additions & 3 deletions frontend/pages/event/[id].vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script setup lang="ts">
import { RoutePathEnum } from '@/constants/enums/route';
import { trimString } from '../../utils/trimString';
import { SeoItemTypeEnum } from '../../constants/enums/seo';

import { apiRouter } from '../../composables/useApiRouter';

Expand Down Expand Up @@ -109,8 +108,6 @@ const onEditButtonClick = async () => {
<main
v-if="posterEvent"
class="event"
itemscope
:itemtype="SeoItemTypeEnum.EVENT"
>
<DetailesImage
:image-url="eventImage"
Expand Down
13 changes: 9 additions & 4 deletions frontend/utils/dates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export const convertEventDateToLocaleString = (
};

export const convertToISOString = (epoch: number, timezoneOffset?: string) => {
const result = dayjs(epoch).utc().format('YYYY-MM-DDTHH:mm:ss');
const result = dayjs(epoch).format('YYYY-MM-DDTHH:mm:ss');
return timezoneOffset ? `${result}${timezoneOffset}` : result;
};

Expand All @@ -182,7 +182,7 @@ export const convertEventDateToISOString = (
} else {
time = epoch;

return convertToISOString(time);
return new Date(epoch).toISOString();
}
};

Expand All @@ -193,11 +193,16 @@ export const getDatesDayDifference = (firstDate: Date, secondDate: Date): number
return Math.ceil(diffTime / day);
};

export const roundTime = (date, interval) => {
export const roundTime = (date: number, interval: number) => {
return Math.ceil(new Date(date).getTime() / (interval * 60 * 1000)) * (interval * 60 * 1000);
};

export const formatDate = (date, isOnline, timezone, duration) => {
export const formatDate = (
date: number,
isOnline: boolean,
timezone: Timezone,
duration: number
) => {
if (duration) {
return `${convertEventDateToLocaleString(date, isOnline, timezone)} -

Expand Down
7 changes: 1 addition & 6 deletions frontend/utils/ld-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ import { SEO_SCHEMA_BASE_URL, SeoItemTypeEnum } from '~/constants/enums/seo';
import type { EventOnPoster } from '../../common/types';
import { VITE_DOMAIN } from '~/constants/url';
import { RoutePathEnum } from '~/constants/enums/route';
import type { LocationQuery } from '#vue-router';
import { convertEventDateToISOString } from './dates';


export const getJSONEventList = (posterEvents: EventOnPoster[], locale: string, path: string) => {

return {
type: 'application/ld+json',
innerHTML: JSON.stringify({
Expand All @@ -32,8 +29,6 @@ export const getJSONEventList = (posterEvents: EventOnPoster[], locale: string,
'@type': 'SearchAction',
target: `${VITE_DOMAIN}${path}?{query}`,
query: 'required'


}
})
};
Expand All @@ -53,7 +48,7 @@ export const getJSONEvent = (posterEvent: EventOnPoster) => {
),
endDate: posterEvent.durationInSeconds
? convertEventDateToISOString(
posterEvent.date,
posterEvent.date + posterEvent.durationInSeconds * 1000,
posterEvent.isOnline,
posterEvent.timezone
)
Expand Down
Loading