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

Articles > stories URL changes #11325

Merged
merged 9 commits into from
Oct 29, 2024
Merged
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
19 changes: 19 additions & 0 deletions common/next/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@ const createConfig =
}
return [...rewriteEntries];
},
async redirects() {
return [
{
source: '/articles/:slug',
destination: '/stories/:slug',
statusCode: 301,
},
{
source: '/articles',
destination: '/search/stories',
statusCode: 301,
},
{
source: '/stories/comic',
destination: '/search/stories?format=W7d_ghAAALWY3Ujc',
statusCode: 301,
},
];
},
webpack: (config, { isServer, webpack }) => {
config.plugins.push(
new webpack.NormalModuleReplacementPlugin(
Expand Down
4 changes: 2 additions & 2 deletions common/services/prismic/link-resolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import linkResolver from './link-resolver';
*/
describe('webcomic edge case', () => {
test.each([
{ doc: { type: 'webcomics', uid: '1' }, path: '/articles/1' },
{ doc: { type: 'webcomics', uid: '1' }, path: '/stories/1' },
{ doc: { type: 'webcomic-series', uid: '1' }, path: '/series/1' },
])('$doc resolves to $path', ({ doc, path }) => {
expect(linkResolver(doc)).toBe(path);
Expand All @@ -20,7 +20,7 @@ it('resolves exhibition guides to /guides/exhibitions/{id}', () => {
});

test.each([
{ doc: { type: 'articles', uid: '1' }, path: '/articles/1' },
{ doc: { type: 'articles', uid: '1' }, path: '/stories/1' },
{ doc: { type: 'pages', uid: '1' }, path: '/1' },
{ doc: { type: 'not a thing', uid: '1' }, path: '/' },
])('$doc resolves to $path', ({ doc, path }) => {
Expand Down
3 changes: 2 additions & 1 deletion common/services/prismic/link-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ function linkResolver(doc: Props | DataProps): string {
const { uid, type } = doc;

if (!uid) return '/';
if (type === 'webcomics') return `/articles/${uid}`;
if (type === 'articles') return `/stories/${uid}`;
if (type === 'webcomics') return `/stories/${uid}`;
if (type === 'webcomic-series') return `/series/${uid}`;
if (
type === 'exhibition-guides' ||
Expand Down
90 changes: 0 additions & 90 deletions content/webapp/pages/articles/index.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import ContentPage from '@weco/content/components/ContentPage/ContentPage';
import PartNumberIndicator from '@weco/content/components/PartNumberIndicator/PartNumberIndicator';
import SeriesNavigation from '@weco/content/components/SeriesNavigation/SeriesNavigation';
import { ArticleFormatIds } from '@weco/content/data/content-format-ids';
import useHotjar from '@weco/content/hooks/useHotjar';
import { createClient } from '@weco/content/services/prismic/fetch';
import {
fetchArticle,
Expand All @@ -43,6 +44,7 @@ import {
getHeroPicture,
} from '@weco/content/utils/page-header';
import { setCacheControl } from '@weco/content/utils/setCacheControl';

const ContentTypeWrapper = styled.div`
display: flex;
align-items: baseline;
Expand Down Expand Up @@ -163,6 +165,7 @@ const HTMLDateWrapper = styled.span.attrs({ className: font('intr', 6) })`
`;

const ArticlePage: FunctionComponent<Props> = ({ article, jsonLd }) => {
useHotjar(true);
const [listOfSeries, setListOfSeries] = useState<ArticleSeriesList>();

useEffect(() => {
Expand Down Expand Up @@ -332,7 +335,7 @@ const ArticlePage: FunctionComponent<Props> = ({ article, jsonLd }) => {
<PageLayout
title={article.title}
description={article.metadataDescription || article.promo?.caption || ''}
url={{ pathname: `/articles/${article.uid}` }}
url={{ pathname: `/stories/${article.uid}` }}
jsonLd={jsonLd}
openGraphType="article"
siteSection="stories"
Expand Down
142 changes: 0 additions & 142 deletions content/webapp/pages/stories/[contentType].tsx

This file was deleted.

8 changes: 5 additions & 3 deletions content/webapp/pages/stories/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ const StoriesPage: FunctionComponent<Props> = ({
<CardGrid
items={storiesLanding.stories}
itemsPerRow={3}
links={[{ text: 'More stories', url: '/articles' }]}
links={[{ text: 'More stories', url: '/search/stories' }]}
/>
</SpacingComponent>
</SpacingSection>
Expand All @@ -269,7 +269,9 @@ const StoriesPage: FunctionComponent<Props> = ({
items={comicSeries}
itemsPerRow={3}
itemsHaveTransparentBackground={true}
links={[{ text: 'More comics', url: '/stories/comic' }]}
links={[
{ text: 'More comics', url: '/stories?format=W7d_ghAAALWY3Ujc' },
]}
/>
</SpacingComponent>
</SpacingSection>
Expand Down Expand Up @@ -307,7 +309,7 @@ const StoriesPage: FunctionComponent<Props> = ({
<CardGrid
items={articles.slice(5, 11)}
itemsPerRow={3}
links={[{ text: 'More stories', url: '/articles' }]}
links={[{ text: 'More stories', url: '/search/stories' }]}
/>
</SpacingComponent>
</SpacingSection>
Expand Down