Skip to content

Commit

Permalink
Merge pull request #160 from storybookjs/charles/sb-1522-move-generat…
Browse files Browse the repository at this point in the history
…ed-redirects-to-middleware

Move generated redirects to middleware
  • Loading branch information
cdedreuille authored Jul 9, 2024
2 parents f366338 + d04fe90 commit 480b096
Show file tree
Hide file tree
Showing 10 changed files with 1,863 additions and 174 deletions.
4 changes: 0 additions & 4 deletions apps/frontpage/next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const generatedRedirects = require('./generated-redirects.json');
const { withPlausibleProxy } = require('next-plausible');

const historicalVersions = [
Expand Down Expand Up @@ -88,8 +87,5 @@ module.exports = withPlausibleProxy()({
'/docs/**': ['./content/docs/**', './content/snippets/**'],
},
},
async redirects() {
return [...generatedRedirects];
},
pageExtensions: ['js', 'jsx', 'mdx', 'ts', 'tsx'],
});
3 changes: 1 addition & 2 deletions apps/frontpage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
"private": true,
"scripts": {
"dev": "next dev",
"build": "npm run fetch-docs && npm run generate-redirects && next build && npm run build:sitemaps",
"build": "npm run fetch-docs && next build && npm run build:sitemaps",
"start": "next start",
"lint": "next lint",
"typecheck": "tsc --noEmit",
"fetch-docs": "tsx --tsconfig tsconfig.json scripts/get-local-docs.ts",
"generate-redirects": "tsx --tsconfig tsconfig.json scripts/generate-redirects.ts",
"copy-other-sitemaps": "tsx --tsconfig tsconfig.json scripts/copy-other-sitemaps.ts",
"build:sitemap": "next-sitemap --config next-sitemap.config.js",
"build:sitemap:all": "next-sitemap --config next-sitemap-all.config.js",
Expand Down
4 changes: 1 addition & 3 deletions apps/frontpage/redirects/docs-common-redirects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,9 @@ export const docsCommonRedirects: RedirectData[] = [
destination: '/docs/faq',
permanent: true,
},
// TODO: Fix - This is a 404
{
source: '/docs/basics/live-examples',
destination:
'https://github.com/storybookjs/storybook/blob/next/examples/README.md',
destination: 'https://github.com/storybookjs/sandboxes',
permanent: true,
},
{
Expand Down
103 changes: 103 additions & 0 deletions apps/frontpage/redirects/docs-version-6-redirects.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import { RedirectData } from './types';

export const docsVersion6Redirects: RedirectData[] = [
{
source: '/docs/6/get-started',
destination: '/docs/6',
permanent: true,
},
// Version 6.4
{
source: '/docs/workflows/testing-with-storybook',
destination: '/docs/writing-tests',
permanent: true,
},
{
source: '/docs/workflows/unit-testing',
destination:
'/docs/writing-tests/import-stories-in-tests/stories-in-unit-tests',
permanent: true,
},
{
source: '/docs/workflows/visual-testing',
destination: '/docs/writing-tests/visual-testing',
permanent: true,
},
{
source: '/docs/workflows/interaction-testing',
destination: '/docs/writing-tests/interaction-testing',
permanent: true,
},
{
source: '/docs/workflows/snapshot-testing',
destination: '/docs/writing-tests/snapshot-testing/snapshot-testing',
permanent: true,
},
{
source: '/docs/workflows/build-pages-with-storybook',
destination: '/docs/writing-stories/build-pages-with-storybook',
permanent: true,
},
{
source: '/docs/workflows/stories-for-multiple-components',
destination: '/docs/writing-stories/stories-for-multiple-components',
permanent: true,
},
{
source: '/docs/workflows/publish-storybook',
destination: '/docs/sharing/publish-storybook',
permanent: true,
},
{
source: '/docs/workflows/storybook-composition',
destination: '/docs/sharing/storybook-composition',
permanent: true,
},
{
source: '/docs/workflows/package-composition',
destination: '/docs/sharing/package-composition',
permanent: true,
},
{
source: '/docs/workflows/faq',
destination: '/docs/faq',
permanent: true,
},
// Version 6.5
{
source: '/docs/configure/webpack',
destination: '/docs/builders/webpack',
permanent: true,
},
{ source: '/docs/api/addons', destination: '/docs/addons', permanent: true },
{
source: '/docs/api/addons-api',
destination: '/docs/addons/addons-api',
permanent: true,
},
{
source: '/docs/api/presets',
destination: '/docs/addons/writing-presets',
permanent: true,
},
{
source: '/docs/addons/addon-catalog',
destination: '/docs/addons/integration-catalog',
permanent: true,
},
{
source: '/docs/api/mdx',
destination: '/docs/writing-docs/mdx',
permanent: true,
},
{
source: '/docs/why-storybook',
destination: '/docs/get-started/why-storybook',
permanent: true,
},
{
source: '/docs/get-started/introduction',
destination: '/docs/get-started/install',
permanent: true,
},
];
119 changes: 119 additions & 0 deletions apps/frontpage/redirects/docs-version-7-redirects.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import { RedirectData } from './types';

export const docsVersion7Redirects: RedirectData[] = [
{
source: '/docs/7/get-started',
destination: '/docs/7',
permanent: true,
},
// Version 7.0
{
source: '/docs/writing-docs/docs-page',
destination: '/docs/writing-docs/autodocs',
permanent: true,
},
{
source: '/docs/writing-docs/doc-block-argstable',
destination: '/docs/api/doc-blocks/doc-block-controls',
permanent: true,
},
{
source: '/docs/writing-docs/doc-block-canvas',
destination: '/docs/api/doc-blocks/doc-block-canvas',
permanent: true,
},
{
source: '/docs/writing-docs/doc-block-colorpalette',
destination: '/docs/api/doc-blocks/doc-block-colorpalette',
permanent: true,
},
{
source: '/docs/writing-docs/doc-block-description',
destination: '/docs/api/doc-blocks/doc-block-description',
permanent: true,
},
{
source: '/docs/writing-docs/doc-block-icongallery',
destination: '/docs/api/doc-blocks/doc-block-icongallery',
permanent: true,
},
{
source: '/docs/writing-docs/doc-block-source',
destination: '/docs/api/doc-blocks/doc-block-source',
permanent: true,
},
{
source: '/docs/writing-docs/doc-block-story',
destination: '/docs/api/doc-blocks/doc-block-story',
permanent: true,
},
{
source: '/docs/writing-docs/doc-block-typeset',
destination: '/docs/api/doc-blocks/doc-block-typeset',
permanent: true,
},
{
source: '/docs/api/frameworks-feature-support',
destination: '/docs/configure/integration/frameworks-feature-support',
permanent: true,
},
{
source: '/docs/api/argtypes',
destination: '/docs/api/arg-types',
permanent: true,
},

//Version7.1
{
source: '/docs/writing-tests/importing-stories-in-tests',
destination: '/docs/writing-tests/stories-in-unit-tests',
permanent: true,
},

//Version7.6
{
source: '/docs/writing-stories/introduction',
destination: '/docs/writing-stories',
permanent: true,
},
{
source: '/docs/writing-docs/introduction',
destination: '/docs/writing-docs',
permanent: true,
},
{
source: '/docs/writing-tests/introduction',
destination: '/docs/writing-tests',
permanent: true,
},
{
source: '/docs/essentials/introduction',
destination: '/docs/essentials',
permanent: true,
},
{
source: '/docs/addons/introduction',
destination: '/docs/addons',
permanent: true,
},
{
source: '/docs/configure/overview',
destination: '/docs/configure',
permanent: true,
},
{
source: '/docs/builders/overview',
destination: '/docs/builders',
permanent: true,
},
{
source: '/docs/contribute/how-to-contribute',
destination: '/docs/contribute',
permanent: true,
},
{
source: '/docs/configure/babel',
destination: '/docs/configure/integration/compilers',
permanent: true,
},
];
Loading

0 comments on commit 480b096

Please sign in to comment.