Skip to content

Commit 8cd52b0

Browse files
committed
fix: dead code
1 parent f3040ba commit 8cd52b0

1 file changed

Lines changed: 7 additions & 31 deletions

File tree

frontend/src/app/[locale]/blog/blog.tsx

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,6 @@ function getTagsAsStrings(tags: unknown): string[] {
2222
});
2323
}
2424

25-
// Fallback used only while a resource has no `resource_type` set in Strapi.
26-
// Once editors fill the field it becomes the source of truth (see transformBlogsData).
27-
function determineType(element: Record<string, any> | null): string {
28-
const title = (element?.title ?? '').toLowerCase();
29-
const media = (element?.media_name ?? '').toLowerCase();
30-
const url = (element?.article_link ?? '').toLowerCase();
31-
32-
if (media === 'rapport' || title.startsWith('rapport') || url.endsWith('.pdf')) return 'rapport';
33-
if (url.includes('/podcast') || url.includes('radiofrance') || title.startsWith('podcast')) return 'podcast';
34-
if (title.startsWith('vidéo') || title.startsWith('video') || title.startsWith('communiqué')) return 'article';
35-
// A named press outlet (not our own brand, not a newsletter) => article.
36-
if (media && media !== 'data for good' && !media.startsWith('newsletter')) return 'article';
37-
return 'autre';
38-
}
39-
40-
// Fallback used only while a resource has no `newsletter` set in Strapi.
41-
function determineNewsletter(element: Record<string, any> | null): string | null {
42-
const media = element?.media_name ?? '';
43-
const title = element?.title ?? '';
44-
if (media === 'Newsletter - Technolucide' || title.startsWith('Techno-Lucide')) return 'techno_lucides';
45-
if (media === "Newsletter - Vers l'autonomie et au-delà" || title.startsWith("Vers l'autonomie")) return 'vers_lautonomie';
46-
return null;
47-
}
48-
4925
// Human labels for the category slugs. These map the values stored in Strapi
5026
// (the `resource_type`/`newsletter` enums, or the `tags` field while those
5127
// enums aren't deployed yet) to what is shown in the filter pills and cards.
@@ -85,18 +61,18 @@ function transformBlogsData(resources: NonNullable<BlogsPageData>): TransformedR
8561

8662
const tagStrings = getTagsAsStrings(element?.tags);
8763

88-
// Categories are read, in priority order, from: the structured Strapi enum
89-
// (once deployed), then the `tags` field (where editors currently store the
90-
// slugs), then a best-effort heuristic. A resource can hold several types
91-
// (e.g. a "communiqué" that is both article and prise de position), so types
92-
// is a list; newsletter is single.
64+
// Categories are read, in priority order, from the structured Strapi enum
65+
// (once deployed) then the `tags` field (where editors currently store the
66+
// slugs); an uncategorized resource defaults to "autre" / no newsletter.
67+
// A resource can hold several types (e.g. a "communiqué" that is both
68+
// article and prise de position), so types is a list; newsletter is single.
9369
const tagTypeSlugs = tagStrings.filter(tag => TYPE_SLUGS.includes(tag));
9470
const types = element?.resource_type
9571
? [element.resource_type]
96-
: (tagTypeSlugs.length > 0 ? tagTypeSlugs : [determineType(element)]);
72+
: (tagTypeSlugs.length > 0 ? tagTypeSlugs : ['autre']);
9773
const newsletter = element?.newsletter
9874
?? tagStrings.find(tag => NEWSLETTER_SLUGS.includes(tag))
99-
?? determineNewsletter(element);
75+
?? null;
10076

10177
const publishedDate = element?.published_date ?? '';
10278
const parsedDate = new Date(publishedDate);

0 commit comments

Comments
 (0)