@wasto/cms-components 1.5.10 → 1.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -47
- package/dist/index.d.mts +181 -51
- package/dist/index.d.ts +181 -51
- package/dist/index.js +3614 -3015
- package/dist/index.mjs +3021 -2418
- package/package.json +12 -2
- package/src/components/announcement-modal/AnnouncementModal.tsx +183 -183
- package/src/components/article/Article.tsx +21 -21
- package/src/components/article/ArticleCard.tsx +81 -81
- package/src/components/article/ArticleExcerpts.tsx +80 -80
- package/src/components/article/ArticleList.tsx +114 -114
- package/src/components/article/ArticleMarkdown.tsx +170 -170
- package/src/components/article/ArticleReaderModal.tsx +93 -93
- package/src/components/article/ArticleSingle.tsx +57 -57
- package/src/components/bottom-tab/BottomTab.tsx +392 -392
- package/src/components/button/Button.tsx +154 -154
- package/src/components/challenge/Badges.tsx +84 -84
- package/src/components/challenge/BadgesModal.tsx +166 -166
- package/src/components/challenge/Challenge.tsx +380 -380
- package/src/components/challenge/ChallengeModal.tsx +231 -231
- package/src/components/challenge/ChallengeVignette.tsx +249 -249
- package/src/components/challenge/ChallengesModal.tsx +243 -243
- package/src/components/challenge/QuizModal.tsx +381 -381
- package/src/components/challenge/ResultModal.tsx +144 -144
- package/src/components/chat/Chat.tsx +928 -928
- package/src/components/collection-calendar/CollectionCalendar.tsx +274 -274
- package/src/components/columns/Columns.tsx +33 -33
- package/src/components/consignes-modal/ConsignesModal.tsx +267 -267
- package/src/components/content-inset/ContentInset.tsx +33 -33
- package/src/components/header/Header.tsx +415 -391
- package/src/components/image/Image.tsx +15 -15
- package/src/components/image/ImageFrame.tsx +102 -102
- package/src/components/image/ImageMedia.tsx +31 -31
- package/src/components/image/ImageUrl.tsx +30 -30
- package/src/components/locations-map/LocationSheet.tsx +417 -417
- package/src/components/locations-map/LocationsMap.native.tsx +260 -260
- package/src/components/locations-map/LocationsMap.tsx +13 -13
- package/src/components/locations-map/LocationsMap.web.tsx +10 -10
- package/src/components/locations-map/LocationsMapShell.tsx +546 -527
- package/src/components/locations-map/LocationsMapView.tsx +108 -108
- package/src/components/locations-map/LocationsMapView.web.tsx +331 -331
- package/src/components/nav-button/NavButton.tsx +59 -59
- package/src/components/next-collection/NextCollection.tsx +636 -621
- package/src/components/notifications/NotificationsScreen.tsx +247 -247
- package/src/components/page/Page.tsx +102 -64
- package/src/components/parapraph/Paragraph.tsx +67 -67
- package/src/components/profile/ProfileScreen.tsx +236 -236
- package/src/components/push/PushTokenRegistrar.tsx +47 -0
- package/src/components/recycling-info/RecyclingInfo.tsx +189 -189
- package/src/components/safe-area/OptionalSafeAreaProvider.tsx +17 -17
- package/src/components/search/Search.tsx +320 -320
- package/src/components/select-street-modal/SelectStreetModal.tsx +475 -475
- package/src/components/title/Title.tsx +100 -100
- package/src/components/vision/Vision.tsx +447 -447
- package/src/components/vision/VisionActionCard.tsx +117 -117
- package/src/components/vision/VisionCapture.tsx +30 -30
- package/src/components/vision/VisionTapOverlay.tsx +122 -122
- package/src/contexts/AnnouncementsContext.tsx +171 -171
- package/src/contexts/AppDataContext.tsx +458 -0
- package/src/contexts/ChallengesContext.tsx +182 -182
- package/src/contexts/HeaderConfigContext.tsx +29 -0
- package/src/contexts/LocalContext.tsx +227 -227
- package/src/contexts/ThemeContext.tsx +37 -37
- package/src/contexts/WastoContext.tsx +132 -127
- package/src/helpers/blogPost.ts +72 -72
- package/src/helpers/generateQuizQuestions.ts +247 -247
- package/src/helpers/getContrastColor.ts +18 -18
- package/src/helpers/haptics.ts +20 -20
- package/src/helpers/hoursSchedule.ts +230 -230
- package/src/helpers/htmlContentToMarkdown.ts +114 -114
- package/src/helpers/layout.ts +54 -54
- package/src/helpers/loadLinearGradient.ts +22 -22
- package/src/helpers/mapLocations.ts +170 -0
- package/src/helpers/maquetteTheme.ts +76 -76
- package/src/helpers/markdownUnderlinePlugin.ts +32 -32
- package/src/helpers/nextCollection.ts +122 -0
- package/src/helpers/normalizeWasteTypeRecyclingInfo.ts +80 -80
- package/src/helpers/publicMediaUrl.ts +8 -8
- package/src/helpers/resolveApiAssetUrl.ts +21 -21
- package/src/helpers/systemRoutes.ts +7 -7
- package/src/helpers/themeStyles.ts +114 -114
- package/src/helpers/ttlCache.ts +41 -0
- package/src/helpers/useSafeAreaPadding.ts +14 -14
- package/src/hooks/useBadges.ts +100 -100
- package/src/hooks/useBlogPosts.ts +109 -105
- package/src/hooks/useChallenges.ts +110 -110
- package/src/hooks/useCities.ts +56 -56
- package/src/hooks/useCityAnnouncements.ts +118 -118
- package/src/hooks/useCollectionCalendar.ts +421 -421
- package/src/hooks/useColumns.ts +19 -19
- package/src/hooks/useConsignes.ts +62 -62
- package/src/hooks/useLocations.ts +120 -248
- package/src/hooks/useNextCollection.ts +163 -238
- package/src/hooks/useRecyclingInfo.ts +90 -90
- package/src/hooks/useWastoClient.ts +16 -16
- package/src/index.ts +161 -142
- package/src/navigation/NavigationContext.tsx +56 -56
- package/src/push/registerExpoPushToken.ts +133 -0
- package/src/sentry/initSentry.ts +120 -120
- package/src/types/Theme.ts +72 -72
- package/src/types/css-modules.d.ts +1 -1
|
@@ -1,127 +1,132 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createContext,
|
|
3
|
-
PropsWithChildren,
|
|
4
|
-
useContext,
|
|
5
|
-
useEffect,
|
|
6
|
-
useMemo,
|
|
7
|
-
type ReactNode,
|
|
8
|
-
} from "react";
|
|
9
|
-
import type { WastoRequestErrorContext } from "@wasto/sdk";
|
|
10
|
-
import { Theme } from "../types/Theme";
|
|
11
|
-
import { ThemeProvider } from "./ThemeContext";
|
|
12
|
-
import { LocalProvider } from "./LocalContext";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
PropsWithChildren,
|
|
4
|
+
useContext,
|
|
5
|
+
useEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
type ReactNode,
|
|
8
|
+
} from "react";
|
|
9
|
+
import type { WastoRequestErrorContext } from "@wasto/sdk";
|
|
10
|
+
import { Theme } from "../types/Theme";
|
|
11
|
+
import { ThemeProvider } from "./ThemeContext";
|
|
12
|
+
import { LocalProvider } from "./LocalContext";
|
|
13
|
+
import { AppDataProvider } from "./AppDataContext";
|
|
14
|
+
import { ChallengesProvider } from "./ChallengesContext";
|
|
15
|
+
import { AnnouncementsProvider } from "./AnnouncementsContext";
|
|
16
|
+
import SelectStreetModal from "../components/select-street-modal/SelectStreetModal";
|
|
17
|
+
import { AnnouncementModal } from "../components/announcement-modal/AnnouncementModal";
|
|
18
|
+
import { PushTokenRegistrar } from "../components/push/PushTokenRegistrar";
|
|
19
|
+
import { OptionalSafeAreaProvider } from "../components/safe-area/OptionalSafeAreaProvider";
|
|
20
|
+
import {
|
|
21
|
+
initWastoSentry,
|
|
22
|
+
reportError as sentryReportError,
|
|
23
|
+
type WastoErrorContext,
|
|
24
|
+
type WastoSentryConfig,
|
|
25
|
+
} from "../sentry/initSentry";
|
|
26
|
+
|
|
27
|
+
export type WastoContextType = {
|
|
28
|
+
apiUrl: string;
|
|
29
|
+
appId: string;
|
|
30
|
+
cityGroupId: string | null;
|
|
31
|
+
/**
|
|
32
|
+
* Studio / iframe preview — no anonymous device registration or challenge writes.
|
|
33
|
+
*/
|
|
34
|
+
previewMode: boolean;
|
|
35
|
+
reportError: (error: unknown, context?: WastoErrorContext) => void;
|
|
36
|
+
onRequestError?: (error: Error, context: WastoRequestErrorContext) => void;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const WastoContext = createContext<WastoContextType | undefined>(undefined);
|
|
40
|
+
|
|
41
|
+
export type WastoProviderProps = PropsWithChildren & {
|
|
42
|
+
apiUrl: string;
|
|
43
|
+
appId: string;
|
|
44
|
+
theme: Theme;
|
|
45
|
+
/** City group scoping street search / multi-city apps. */
|
|
46
|
+
cityGroupId?: string | null;
|
|
47
|
+
/** GitLab Error Tracking / Sentry config (DSN from env). */
|
|
48
|
+
sentry?: WastoSentryConfig;
|
|
49
|
+
/**
|
|
50
|
+
* When true (Studio preview): LocalContext skips analytics.track / device id.
|
|
51
|
+
*/
|
|
52
|
+
previewMode?: boolean;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export function WastoProvider(props: WastoProviderProps): ReactNode {
|
|
56
|
+
const apiUrl = useMemo(() => props.apiUrl, [props.apiUrl]);
|
|
57
|
+
const appId = useMemo(() => props.appId, [props.appId]);
|
|
58
|
+
const cityGroupId = useMemo(
|
|
59
|
+
() => props.cityGroupId?.trim() || null,
|
|
60
|
+
[props.cityGroupId],
|
|
61
|
+
);
|
|
62
|
+
const previewMode = Boolean(props.previewMode);
|
|
63
|
+
const sentryConfig = props.sentry;
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (!sentryConfig) return;
|
|
67
|
+
initWastoSentry({
|
|
68
|
+
...sentryConfig,
|
|
69
|
+
appId: sentryConfig.appId ?? appId,
|
|
70
|
+
});
|
|
71
|
+
}, [appId, sentryConfig]);
|
|
72
|
+
|
|
73
|
+
const reportError = useMemo(
|
|
74
|
+
() => (error: unknown, context?: WastoErrorContext) => {
|
|
75
|
+
sentryReportError(error, context);
|
|
76
|
+
},
|
|
77
|
+
[],
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const onRequestError = useMemo(
|
|
81
|
+
() => (error: Error, ctx: WastoRequestErrorContext) => {
|
|
82
|
+
reportError(error, {
|
|
83
|
+
source: "api",
|
|
84
|
+
method: ctx.method,
|
|
85
|
+
path: ctx.path,
|
|
86
|
+
status: ctx.status,
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
[reportError],
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const value = useMemo<WastoContextType>(
|
|
93
|
+
() => ({
|
|
94
|
+
apiUrl,
|
|
95
|
+
appId,
|
|
96
|
+
cityGroupId,
|
|
97
|
+
previewMode,
|
|
98
|
+
reportError,
|
|
99
|
+
onRequestError,
|
|
100
|
+
}),
|
|
101
|
+
[apiUrl, appId, cityGroupId, previewMode, reportError, onRequestError],
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<WastoContext value={value}>
|
|
106
|
+
<OptionalSafeAreaProvider>
|
|
107
|
+
<LocalProvider previewMode={previewMode}>
|
|
108
|
+
<PushTokenRegistrar />
|
|
109
|
+
<ChallengesProvider>
|
|
110
|
+
<AnnouncementsProvider apiUrl={apiUrl}>
|
|
111
|
+
<ThemeProvider theme={props.theme}>
|
|
112
|
+
<AppDataProvider apiUrl={apiUrl}>
|
|
113
|
+
{props.children}
|
|
114
|
+
<SelectStreetModal />
|
|
115
|
+
<AnnouncementModal />
|
|
116
|
+
</AppDataProvider>
|
|
117
|
+
</ThemeProvider>
|
|
118
|
+
</AnnouncementsProvider>
|
|
119
|
+
</ChallengesProvider>
|
|
120
|
+
</LocalProvider>
|
|
121
|
+
</OptionalSafeAreaProvider>
|
|
122
|
+
</WastoContext>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function useWasto() {
|
|
127
|
+
const context = useContext(WastoContext);
|
|
128
|
+
if (!context) {
|
|
129
|
+
throw new Error("useContext must be used within a WastoProvider.");
|
|
130
|
+
}
|
|
131
|
+
return context;
|
|
132
|
+
}
|
package/src/helpers/blogPost.ts
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { htmlContentToMarkdown } from "./htmlContentToMarkdown";
|
|
2
|
-
|
|
3
|
-
export type BlogPost = {
|
|
4
|
-
id: string;
|
|
5
|
-
title: string;
|
|
6
|
-
content: string;
|
|
7
|
-
publishedAt?: string;
|
|
8
|
-
createdAt?: string;
|
|
9
|
-
coverMediaId?: string | null;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
function asRecord(raw: unknown): Record<string, unknown> | null {
|
|
13
|
-
if (raw == null || typeof raw !== "object") return null;
|
|
14
|
-
const root = raw as Record<string, unknown>;
|
|
15
|
-
if (root.data != null && typeof root.data === "object") {
|
|
16
|
-
return root.data as Record<string, unknown>;
|
|
17
|
-
}
|
|
18
|
-
return root;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function pickStr(o: Record<string, unknown>, camel: string, snake?: string): string | undefined {
|
|
22
|
-
const v = o[camel] ?? (snake ? o[snake] : undefined);
|
|
23
|
-
return typeof v === "string" ? v : undefined;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function normalizeBlogPost(raw: unknown): BlogPost | null {
|
|
27
|
-
const o = asRecord(raw);
|
|
28
|
-
if (!o) return null;
|
|
29
|
-
|
|
30
|
-
const idRaw = o.id;
|
|
31
|
-
const id = typeof idRaw === "string" ? idRaw : idRaw != null ? String(idRaw) : "";
|
|
32
|
-
if (!id) return null;
|
|
33
|
-
|
|
34
|
-
const coverFromRelation =
|
|
35
|
-
o.coverMedia != null && typeof o.coverMedia === "object"
|
|
36
|
-
? (o.coverMedia as { id?: unknown }).id
|
|
37
|
-
: undefined;
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
id,
|
|
41
|
-
title: pickStr(o, "title") || "Sans titre",
|
|
42
|
-
content: pickStr(o, "content") || "",
|
|
43
|
-
publishedAt: pickStr(o, "publishedAt", "published_at"),
|
|
44
|
-
createdAt: pickStr(o, "createdAt", "created_at"),
|
|
45
|
-
coverMediaId:
|
|
46
|
-
pickStr(o, "coverMediaId", "cover_media_id") ??
|
|
47
|
-
(typeof coverFromRelation === "string" ? coverFromRelation : null),
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function stripToExcerpt(content: string, maxLen = 180): string {
|
|
52
|
-
const fromHtml = htmlContentToMarkdown(content);
|
|
53
|
-
const plain = fromHtml
|
|
54
|
-
.replace(/```[\s\S]*?```/g, " ")
|
|
55
|
-
.replace(/`[^`]*`/g, " ")
|
|
56
|
-
.replace(/!\[[^\]]*]\([^)]*\)/g, " ")
|
|
57
|
-
.replace(/\[[^\]]*]\([^)]*\)/g, " ")
|
|
58
|
-
.replace(/\+\+([^+]+)\+\+/g, "$1")
|
|
59
|
-
.replace(/[#>*_~\-|]+/g, " ")
|
|
60
|
-
.replace(/\s+/g, " ")
|
|
61
|
-
.trim();
|
|
62
|
-
if (plain.length <= maxLen) return plain;
|
|
63
|
-
return `${plain.slice(0, maxLen).trim()}…`;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function formatArticleDate(value?: string): string | undefined {
|
|
67
|
-
if (!value) return undefined;
|
|
68
|
-
const slice = value.length >= 10 ? value.slice(0, 10) : value;
|
|
69
|
-
const date = new Date(slice);
|
|
70
|
-
if (Number.isNaN(date.getTime())) return slice;
|
|
71
|
-
return date.toLocaleDateString("fr-FR", { day: "numeric", month: "long", year: "numeric" });
|
|
72
|
-
}
|
|
1
|
+
import { htmlContentToMarkdown } from "./htmlContentToMarkdown";
|
|
2
|
+
|
|
3
|
+
export type BlogPost = {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
content: string;
|
|
7
|
+
publishedAt?: string;
|
|
8
|
+
createdAt?: string;
|
|
9
|
+
coverMediaId?: string | null;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
function asRecord(raw: unknown): Record<string, unknown> | null {
|
|
13
|
+
if (raw == null || typeof raw !== "object") return null;
|
|
14
|
+
const root = raw as Record<string, unknown>;
|
|
15
|
+
if (root.data != null && typeof root.data === "object") {
|
|
16
|
+
return root.data as Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
return root;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function pickStr(o: Record<string, unknown>, camel: string, snake?: string): string | undefined {
|
|
22
|
+
const v = o[camel] ?? (snake ? o[snake] : undefined);
|
|
23
|
+
return typeof v === "string" ? v : undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function normalizeBlogPost(raw: unknown): BlogPost | null {
|
|
27
|
+
const o = asRecord(raw);
|
|
28
|
+
if (!o) return null;
|
|
29
|
+
|
|
30
|
+
const idRaw = o.id;
|
|
31
|
+
const id = typeof idRaw === "string" ? idRaw : idRaw != null ? String(idRaw) : "";
|
|
32
|
+
if (!id) return null;
|
|
33
|
+
|
|
34
|
+
const coverFromRelation =
|
|
35
|
+
o.coverMedia != null && typeof o.coverMedia === "object"
|
|
36
|
+
? (o.coverMedia as { id?: unknown }).id
|
|
37
|
+
: undefined;
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
id,
|
|
41
|
+
title: pickStr(o, "title") || "Sans titre",
|
|
42
|
+
content: pickStr(o, "content") || "",
|
|
43
|
+
publishedAt: pickStr(o, "publishedAt", "published_at"),
|
|
44
|
+
createdAt: pickStr(o, "createdAt", "created_at"),
|
|
45
|
+
coverMediaId:
|
|
46
|
+
pickStr(o, "coverMediaId", "cover_media_id") ??
|
|
47
|
+
(typeof coverFromRelation === "string" ? coverFromRelation : null),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function stripToExcerpt(content: string, maxLen = 180): string {
|
|
52
|
+
const fromHtml = htmlContentToMarkdown(content);
|
|
53
|
+
const plain = fromHtml
|
|
54
|
+
.replace(/```[\s\S]*?```/g, " ")
|
|
55
|
+
.replace(/`[^`]*`/g, " ")
|
|
56
|
+
.replace(/!\[[^\]]*]\([^)]*\)/g, " ")
|
|
57
|
+
.replace(/\[[^\]]*]\([^)]*\)/g, " ")
|
|
58
|
+
.replace(/\+\+([^+]+)\+\+/g, "$1")
|
|
59
|
+
.replace(/[#>*_~\-|]+/g, " ")
|
|
60
|
+
.replace(/\s+/g, " ")
|
|
61
|
+
.trim();
|
|
62
|
+
if (plain.length <= maxLen) return plain;
|
|
63
|
+
return `${plain.slice(0, maxLen).trim()}…`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function formatArticleDate(value?: string): string | undefined {
|
|
67
|
+
if (!value) return undefined;
|
|
68
|
+
const slice = value.length >= 10 ? value.slice(0, 10) : value;
|
|
69
|
+
const date = new Date(slice);
|
|
70
|
+
if (Number.isNaN(date.getTime())) return slice;
|
|
71
|
+
return date.toLocaleDateString("fr-FR", { day: "numeric", month: "long", year: "numeric" });
|
|
72
|
+
}
|