Skip to content

Commit ecfe70e

Browse files
committed
tweak pagination logic and side text
1 parent 53c049a commit ecfe70e

3 files changed

Lines changed: 56 additions & 38 deletions

File tree

dotcom-rendering/src/components/StorylinesSection.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,14 +597,27 @@ export const StorylinesSection = ({
597597
${textSans14};
598598
`}
599599
>
600-
Dive deeper into the Guardian's archive.{' '}
601600
<Hide until="leftCol">
602601
<span>
603-
This product uses GenAI. Learn more
604-
about how it works{' '}
602+
Storylines is an experimental
603+
feature we are showing to a limited
604+
audience as a Beta test.
605+
<br /> It uses generative AI to
606+
identify three key storylines within
607+
this topic and show valuable
608+
articles from our archive. The aim
609+
is to give readers a better
610+
understanding of a topic and access
611+
to a wider variety of our
612+
journalism. The only text
613+
automatically generated is the short
614+
description of each storyline. It
615+
has been created in line with the
616+
Guardian’s{' '}
605617
<a href="https://www.theguardian.com/help/insideguardian/2023/jun/16/the-guardians-approach-to-generative-ai">
606-
here.
618+
generative AI principles
607619
</a>
620+
.{' '}
608621
</span>
609622

610623
<div
@@ -674,6 +687,7 @@ export const StorylinesSection = ({
674687
align-items: center;
675688
height: 100%;
676689
width: 48px;
690+
padding: ${space[1]}px;
677691
`}
678692
>
679693
<SvgBetaLabel />

dotcom-rendering/src/components/StorylinesSectionContent.importable.tsx

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,7 @@ function formatDateRangeText(
126126
const format = (d?: Date | null) => {
127127
if (!d) return '';
128128
const day = d.getDate();
129-
const suffix = (dayNum: number) => {
130-
if (dayNum > 3 && dayNum < 21) return 'th';
131-
switch (dayNum % 10) {
132-
case 1:
133-
return 'st';
134-
case 2:
135-
return 'nd';
136-
case 3:
137-
return 'rd';
138-
default:
139-
return 'th';
140-
}
141-
};
142-
return `${day}${suffix(day)} ${d.toLocaleDateString('en-GB', {
129+
return `${day} ${d.toLocaleDateString('en-GB', {
143130
month: 'long',
144131
year: 'numeric',
145132
})}`;
@@ -280,19 +267,33 @@ export const StorylinesSectionContent = ({
280267
{/* Context on article date range and mobile AI disclaimer */}
281268
<div css={articleDateRangeStyle}>
282269
<Hide from="leftCol">
283-
<span>
284-
This product uses GenAI. Learn more about how it
285-
works{' '}
270+
<div
271+
css={css`
272+
padding-bottom: ${space[2]}px;
273+
`}
274+
>
275+
Storylines is an experimental feature we are showing
276+
to a limited audience as a Beta test. It uses
277+
generative AI to identify three key storylines
278+
within this topic and show valuable articles from
279+
our archive. The aim is to give readers a better
280+
understanding of a topic and access to a wider
281+
variety of our journalism. The only text
282+
automatically generated is the short description of
283+
each storyline. It has been created in line with the
284+
Guardian’s{' '}
286285
<a href="https://www.theguardian.com/help/insideguardian/2023/jun/16/the-guardians-approach-to-generative-ai">
287-
here
286+
generative AI principles
288287
</a>
289288
.{' '}
290-
</span>
289+
</div>
291290
</Hide>
292-
{`These storylines were curated from ${formatDateRangeText(
293-
storylinesContent.earliestArticleTime,
294-
storylinesContent.latestArticleTime,
295-
)}. Some articles may be older to provide further context.`}
291+
<div>
292+
{`These storylines were curated from ${formatDateRangeText(
293+
storylinesContent.earliestArticleTime,
294+
storylinesContent.latestArticleTime,
295+
)}. Some articles may be older to provide further context.`}
296+
</div>
296297
</div>
297298

298299
<Hide from="leftCol">

dotcom-rendering/src/layouts/TagPageLayout.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,23 @@ export const TagPageLayout = ({ tagPage, NAV }: Props) => {
147147
* If the storylines section is being inserted when there's only one other container on the page,
148148
* we want to attach the pagination to it instead of the last trails section.
149149
*/
150+
const isLastGroup =
151+
index === tagPage.groupedTrails.length - 1;
152+
const hasPagination = !!tagPage.pagination;
153+
const isSingleGroup = tagPage.groupedTrails.length === 1;
154+
const shouldSuppressPagination =
155+
insertStorylinesSection && isSingleGroup;
156+
150157
const tagPagePagination =
151-
index === tagPage.groupedTrails.length - 1 &&
152-
tagPage.pagination &&
153-
!(
154-
insertStorylinesSection &&
155-
tagPage.groupedTrails.length === 1
156-
)
158+
isLastGroup &&
159+
hasPagination &&
160+
!shouldSuppressPagination
157161
? tagPage.pagination
158162
: undefined;
159163

160-
const paginationForStorylines =
161-
tagPage.groupedTrails.length === 1
162-
? tagPage.pagination
163-
: undefined;
164+
const storylinesPagination = isSingleGroup
165+
? tagPage.pagination
166+
: undefined;
164167

165168
return (
166169
<Fragment key={containerId}>
@@ -213,7 +216,7 @@ export const TagPageLayout = ({ tagPage, NAV }: Props) => {
213216
tagPage.storylinesContent
214217
}
215218
containerId="storylines"
216-
pagination={paginationForStorylines}
219+
pagination={storylinesPagination}
217220
/>
218221
</Island>
219222
)}

0 commit comments

Comments
 (0)