diff --git a/packages/web-shared/embeds/FeatureFeed.js b/packages/web-shared/embeds/FeatureFeed.js
index 1b07cdb0..31713e6f 100644
--- a/packages/web-shared/embeds/FeatureFeed.js
+++ b/packages/web-shared/embeds/FeatureFeed.js
@@ -14,68 +14,32 @@ import { Box } from '../ui-kit';
import { useSearchParams } from 'react-router-dom';
import { parseSlugToIdAndType } from '../utils';
import { useAnalytics } from '../providers/AnalyticsProvider';
+import { getComponentFromType } from '../utils/getContentFromURL';
function RenderFeatures(props) {
const [searchParams] = useSearchParams();
const _id = searchParams.get('id');
const { type, randomId } = parseSlugToIdAndType(_id) ?? {};
- switch (type) {
- case 'MediaContentItem':
- case 'WeekendContentItem':
- case 'Event':
- case 'UniversalContentItem': {
- const options = {
- variables: { id: `${type}:${randomId}` },
- };
+ const Component = getComponentFromType({ type, id: randomId });
- return ;
- }
- case 'ContentSeriesContentItem': {
- const options = {
- variables: { id: `${type}:${randomId}` },
- };
-
- return ;
- }
- case 'Livestream': {
- const options = {
- variables: { id: `${type}:${randomId}` },
- };
-
- return ;
- }
- case 'ContentChannel': {
- const options = {
- variables: { id: `${type}:${randomId}` },
- };
- return ;
- }
- case 'Url': {
- return
External Url
;
- }
- case 'FeatureFeed': {
- const options = {
- variables: { itemId: `${type}:${randomId}` },
- };
- return ;
- }
- default: {
- return (
-
-
-
- );
- }
+ if (Component) {
+ return Component;
}
+ // If not component is found, fallback to a FeatureFeed
+ return (
+
+
+
+ );
}
const FeatureFeed = (props) => {
@@ -84,10 +48,10 @@ const FeatureFeed = (props) => {
const analytics = useAnalytics();
useEffect(() => {
- console.log(props)
+ console.log(props);
analytics.track('ViewFeatureFeed', {
featureFeedId: props.featureFeed,
- })
+ });
}, []);
return (
diff --git a/packages/web-shared/utils/getContentFromURL.js b/packages/web-shared/utils/getContentFromURL.js
index ead6693f..e32f2929 100644
--- a/packages/web-shared/utils/getContentFromURL.js
+++ b/packages/web-shared/utils/getContentFromURL.js
@@ -11,36 +11,35 @@ import {
import parseSlugToIdAndType from './parseSlugToIdAndType';
import { Box } from '../ui-kit';
-function getContentFromURL(url) {
- const { type, randomId } = parseSlugToIdAndType(url);
-
+export function getComponentFromType({ type, id }) {
switch (type) {
case 'MediaContentItem':
case 'WeekendContentItem':
+ case 'Event':
case 'UniversalContentItem': {
const options = {
- variables: { id: `${type}:${randomId}` },
+ variables: { id: `${type}:${id}` },
};
return ;
}
case 'ContentSeriesContentItem': {
const options = {
- variables: { id: `${type}:${randomId}` },
+ variables: { id: `${type}:${id}` },
};
return ;
}
case 'Livestream': {
const options = {
- variables: { id: `${type}:${randomId}` },
+ variables: { id: `${type}:${id}` },
};
return ;
}
case 'ContentChannel': {
const options = {
- variables: { id: `${type}:${randomId}` },
+ variables: { id: `${type}:${id}` },
};
return ;
}
@@ -49,14 +48,20 @@ function getContentFromURL(url) {
}
case 'FeatureFeed': {
const options = {
- variables: { itemId: `${type}:${randomId}` },
+ variables: { itemId: `${type}:${id}` },
};
return ;
}
default: {
- return No Content;
+ return null;
}
}
}
+function getContentFromURL(url) {
+ const { type, randomId } = parseSlugToIdAndType(url) ?? {};
+
+ return getComponentFromType({ type, id: randomId });
+}
+
export default getContentFromURL;