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

Playing around with moving OJs into main content #11572

Draft
wants to merge 1 commit into
base: latest
Choose a base branch
from
Draft
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
29 changes: 28 additions & 1 deletion src/app/pages/ArticlePage/ArticlePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import ComscoreAnalytics from '#containers/ComscoreAnalytics';
import articleMediaPlayer from '#containers/ArticleMediaPlayer';
import SocialEmbedContainer from '#containers/SocialEmbed';
import TopStoriesSection from './PagePromoSections/TopStoriesSection';

Check failure on line 23 in src/app/pages/ArticlePage/ArticlePage.jsx

View workflow job for this annotation

GitHub Actions / build (18.x)

`./PagePromoSections/TopStoriesSection` import should occur after import of `#app/routes/utils/pageTypes`

import {
getArticleId,
Expand Down Expand Up @@ -88,7 +89,24 @@
const lastPublished = getLastPublished(pageData);
const aboutTags = getAboutTags(pageData);
const topics = path(['metadata', 'topics'], pageData);
const blocks = pathOr([], ['content', 'model', 'blocks'], pageData);
let blocks = pathOr([], ['content', 'model', 'blocks'], pageData);

// start top stories spike
// q: there is currently no consideration of isAmp and so this is running on all routes using the ArticlePage page.
// again, is there a place where isAmp could be mapped to a prop to vary on higher up the chain? maybe the `getInitialData` function?
const topStoriesContent = path(['secondaryColumn', 'topStories'], pageData);
// q: is there any concept of transformers/transformation in Simorgh. We could create an experimentalTopStories block instead of copying the code from the secondary column
// we might want to experiment on more than the position such as the title of the block, number of top stories shown
const topStoriesBlock = { type: 'topStories', model: topStoriesContent, id: 'topStories', position: 0, blockGroupType: 'topStories', blockGroupIndex: 0 }; // these should be made more programatically

Check failure on line 100 in src/app/pages/ArticlePage/ArticlePage.jsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `·type:·'topStories',·model:·topStoriesContent,·id:·'topStories',·position:·0,·blockGroupType:·'topStories',·blockGroupIndex:·0` with `⏎····type:·'topStories',⏎····model:·topStoriesContent,⏎····id:·'topStories',⏎····position:·0,⏎····blockGroupType:·'topStories',⏎····blockGroupIndex:·0,⏎·`
const halfway = parseInt(blocks.length / 2) + 1; // randomly picked halfway through the article (we might want to vary this value with Optimizely)

Check failure on line 101 in src/app/pages/ArticlePage/ArticlePage.jsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Missing radix parameter

Check failure on line 102 in src/app/pages/ArticlePage/ArticlePage.jsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Delete `··`
// stolen from the articles transformer as we have done this kind of messing with block order there.
// There might be a more Simorgh way of doing this?
const blocksBeforeInsertIndex = blocks.slice(0, halfway);
const blocksAfterInsertIndex = blocks.slice(halfway, blocks.length);
blocks = [...blocksBeforeInsertIndex, topStoriesBlock, ...blocksAfterInsertIndex]

Check failure on line 107 in src/app/pages/ArticlePage/ArticlePage.jsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `...blocksBeforeInsertIndex,·topStoriesBlock,·...blocksAfterInsertIndex]` with `⏎····...blocksBeforeInsertIndex,⏎····topStoriesBlock,⏎····...blocksAfterInsertIndex,⏎··];`
// end top stories spike

const startsWithHeading = propEq('type', 'headline')(blocks[0] || {});

const bylineBlock = blocks.find(block => block.type === 'byline');
Expand Down Expand Up @@ -165,6 +183,15 @@
<Disclaimer {...props} increasePaddingOnDesktop={false} />
),
podcastPromo: () => (podcastPromoEnabled ? <InlinePodcastPromo /> : null),
// this works, but I wonder if we would prefer a more explicit approach to make sure this is clear as an experiment
topStories: () => (topStoriesContent ? (

Check failure on line 187 in src/app/pages/ArticlePage/ArticlePage.jsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `·(` with `⏎······`
<div

Check failure on line 188 in src/app/pages/ArticlePage/ArticlePage.jsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Insert `··`
css={styles.topStoriesAndFeaturesSection}

Check failure on line 189 in src/app/pages/ArticlePage/ArticlePage.jsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Insert `··`
data-testid="top-stories"

Check failure on line 190 in src/app/pages/ArticlePage/ArticlePage.jsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Insert `··`
>

Check failure on line 191 in src/app/pages/ArticlePage/ArticlePage.jsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Insert `··`
<TopStoriesSection content={topStoriesContent} />
</div>
) : null),
};

const visuallyHiddenBlock = {
Expand Down
2 changes: 1 addition & 1 deletion src/server/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ server.get(
`https://www.bbcweb3hytmzhn5d532owbu6oqadra5z3ar726vq5kgwwn6aucdccrad.onion${urlPath}`,
);

const mvtVaryHeaders = !isAmp && getMvtVaryHeaders(mvtExperiments);
const mvtVaryHeaders = !isAmp && getMvtVaryHeaders(mvtExperiments); // does this mean AMP cannot do experiments?

if (mvtVaryHeaders) res.set('vary', mvtVaryHeaders);
res.status(status).send(result.html);
Expand Down
Loading