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

Redirects #7067

Merged
merged 49 commits into from
Jun 5, 2023
Merged

Redirects #7067

merged 49 commits into from
Jun 5, 2023

Conversation

matthewp
Copy link
Contributor

@matthewp matthewp commented May 11, 2023

Preview release

Note that this is now available as a preview release. You can install with:

npm install astro@next--redirects

Then you can set up redirects in your config:

import { defineConfig } from 'astro/config';

export default defineConfig({
  redirects: {
    '/other': '/place'
  }
});

Additionally you can use Astro.redirect in components.

Output

With this preview release the output works in 2 ways:

  • An HTML file is written out with: <meta http-equiv="refresh" content="0;url=/" />
  • If you use the Netlify netlifyStatic adapter it will also write out the appropriate _redirects file for you.

Changes

Testing

Docs

@changeset-bot
Copy link

changeset-bot bot commented May 11, 2023

🦋 Changeset detected

Latest commit: 33a9d5f

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope) labels May 11, 2023
@github-actions github-actions bot added the semver: minor Change triggers a `minor` release label May 11, 2023
@github-actions
Copy link
Contributor

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

@matthewp
Copy link
Contributor Author

!preview redirects

@github-actions
Copy link
Contributor

 > [email protected] release /home/runner/work/astro/astro > pnpm run build && changeset publish "--tag" "next--redirects" > [email protected] build /home/runner/work/astro/astro > turbo run build --filter=astro --filter=create-astro --filter="@astrojs/*" --filter="@benchmark/*" �[2m• Packages in scope: @astrojs/alpinejs, @astrojs/cloudflare, @astrojs/deno, @astrojs/image, @astrojs/lit, @astrojs/markdoc, @astrojs/markdown-component, @astrojs/markdown-remark, @astrojs/mdx, @astrojs/netlify, @astrojs/node, @astrojs/partytown, @astrojs/preact, @astrojs/prefetch, @astrojs/prism, @astrojs/react, @astrojs/rss, @astrojs/sitemap, @astrojs/solid-js, @astrojs/svelte, @astrojs/tailwind, @astrojs/telemetry, @astrojs/turbolinks, @astrojs/vercel, @astrojs/vue, @astrojs/webapi, @benchmark/timer, astro, create-astro�[0m �[2m• Running�[0m �[2m�[1mbuild�[0m�[0m �[2min 29 packages�[0m �[2m• Remote caching enabled�[0m �[35m@astrojs/webapi:build: �[0mcache hit, suppressing output �[2m43127657c4838cc4�[0m �[32mcreate-astro:build: �[0mcache hit, suppressing output �[2me199469c305595ba�[0m �[33m@astrojs/prism:build: �[0mcache hit, suppressing output �[2me9526716746c0757�[0m �[34m@astrojs/telemetry:build: �[0mcache hit, suppressing output �[2m4255fc58189978b2�[0m �[36m@astrojs/markdown-remark:build: �[0mcache hit, suppressing output �[2m637ba7743659c9bd�[0m �[35mastro:build: �[0mcache miss, executing �[2m2a54a5d7946acc86�[0m �[35mastro:build: �[0m �[35mastro:build: �[0m> [email protected] build /home/runner/work/astro/astro/packages/astro �[35mastro:build: �[0m> pnpm run prebuild && astro-scripts build "src/**/*.{ts,js}" && tsc && pnpm run postbuild �[35mastro:build: �[0m �[35mastro:build: �[0m �[35mastro:build: �[0m> [email protected] prebuild /home/runner/work/astro/astro/packages/astro �[35mastro:build: �[0m> astro-scripts prebuild --to-string "src/runtime/server/astro-island.ts" "src/runtime/client/{idle,load,media,only,visible}.ts" �[35mastro:build: �[0m �[35mastro:build: �[0m �[35mastro:build: �[0m> [email protected] postbuild /home/runner/work/astro/astro/packages/astro �[35mastro:build: �[0m> astro-scripts copy "src/**/*.astro" && astro-scripts copy "src/**/*.wasm" �[35mastro:build: �[0m �[32m@astrojs/markdoc:build: �[0mcache miss, executing �[2md5a45ecac66b6204�[0m �[35m@astrojs/cloudflare:build: �[0mcache miss, executing �[2m02b7a868462f3d78�[0m �[33m@astrojs/svelte:build: �[0mcache miss, executing �[2m3a73e87f5a642a91�[0m �[34m@astrojs/turbolinks:build: �[0mcache miss, executing �[2m5b3d4b911699c361�[0m �[36m@astrojs/prefetch:build: �[0mcache miss, executing �[2mac7ea4ce4a8d9646�[0m �[34m@astrojs/deno:build: �[0mcache miss, executing �[2mf57cb8b132050a8b�[0m �[33m@astrojs/vue:build: �[0mcache miss, executing �[2m2d6525fc183dd433�[0m �[35m@astrojs/rss:build: �[0mcache miss, executing �[2m2be56d77884dad12�[0m �[36m@astrojs/vercel:build: �[0mcache miss, executing �[2md7a3b2087edaa116�[0m �[32m@astrojs/partytown:build: �[0mcache miss, executing �[2m988e5d6f4397cc25�[0m �[34m@astrojs/turbolinks:build: �[0m �[34m@astrojs/turbolinks:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/turbolinks �[34m@astrojs/turbolinks:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[34m@astrojs/turbolinks:build: �[0m �[35m@astrojs/cloudflare:build: �[0m �[35m@astrojs/cloudflare:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/cloudflare �[35m@astrojs/cloudflare:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[35m@astrojs/cloudflare:build: �[0m �[33m@astrojs/svelte:build: �[0m �[33m@astrojs/svelte:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/svelte �[33m@astrojs/svelte:build: �[0m> astro-scripts build "src/index.ts" && astro-scripts build "src/editor.cts" --force-cjs --no-clean-dist && tsc �[33m@astrojs/svelte:build: �[0m �[33m@astrojs/vue:build: �[0m �[33m@astrojs/vue:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/vue �[33m@astrojs/vue:build: �[0m> astro-scripts build "src/index.ts" && astro-scripts build "src/editor.cts" --force-cjs --no-clean-dist && tsc �[33m@astrojs/vue:build: �[0m �[32m@astrojs/markdoc:build: �[0m �[32m@astrojs/markdoc:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/markdoc �[32m@astrojs/markdoc:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[32m@astrojs/markdoc:build: �[0m �[36m@astrojs/prefetch:build: �[0m �[36m@astrojs/prefetch:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/prefetch �[36m@astrojs/prefetch:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[36m@astrojs/prefetch:build: �[0m �[34m@astrojs/deno:build: �[0m �[34m@astrojs/deno:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/deno �[34m@astrojs/deno:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[34m@astrojs/deno:build: �[0m �[35m@astrojs/rss:build: �[0m �[35m@astrojs/rss:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/astro-rss �[35m@astrojs/rss:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[35m@astrojs/rss:build: �[0m �[36m@astrojs/vercel:build: �[0m �[36m@astrojs/vercel:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/vercel �[36m@astrojs/vercel:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[36m@astrojs/vercel:build: �[0m �[32m@astrojs/partytown:build: �[0m �[32m@astrojs/partytown:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/partytown �[32m@astrojs/partytown:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[32m@astrojs/partytown:build: �[0m �[32m@astrojs/mdx:build: �[0mcache miss, executing �[2md36990a47d66e6c3�[0m �[33m@astrojs/netlify:build: �[0mcache miss, executing �[2m0c6e885bf278268f�[0m �[34m@astrojs/preact:build: �[0mcache miss, executing �[2md6bba493e4388219�[0m �[35m@astrojs/image:build: �[0mcache miss, executing �[2mf108867a6719acca�[0m �[36m@astrojs/alpinejs:build: �[0mcache miss, executing �[2ma1b9f3bbcc42337c�[0m �[32m@astrojs/mdx:build: �[0m �[32m@astrojs/mdx:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/mdx �[32m@astrojs/mdx:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[32m@astrojs/mdx:build: �[0m �[32m@astrojs/react:build: �[0mcache miss, executing �[2m6ef521004464706d�[0m �[33m@benchmark/timer:build: �[0mcache miss, executing �[2mda789f11bd4ed225�[0m �[36m@astrojs/node:build: �[0mcache miss, executing �[2m6b6f2bebab358d0a�[0m �[34m@astrojs/lit:build: �[0mcache miss, executing �[2ma518316e0abc91a1�[0m �[33m@astrojs/netlify:build: �[0m �[33m@astrojs/netlify:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/netlify �[33m@astrojs/netlify:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[33m@astrojs/netlify:build: �[0m �[34m@astrojs/preact:build: �[0m �[34m@astrojs/preact:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/preact �[34m@astrojs/preact:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[34m@astrojs/preact:build: �[0m �[35m@astrojs/solid-js:build: �[0mcache miss, executing �[2m892c023b964d33c2�[0m �[35m@astrojs/image:build: �[0m �[35m@astrojs/image:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/image �[35m@astrojs/image:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[35m@astrojs/image:build: �[0m �[36m@astrojs/alpinejs:build: �[0m �[36m@astrojs/alpinejs:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/alpinejs �[36m@astrojs/alpinejs:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[36m@astrojs/alpinejs:build: �[0m �[32m@astrojs/react:build: �[0m �[32m@astrojs/react:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/react �[32m@astrojs/react:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[32m@astrojs/react:build: �[0m �[34m@astrojs/lit:build: �[0m �[34m@astrojs/lit:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/lit �[34m@astrojs/lit:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[34m@astrojs/lit:build: �[0m �[33m@benchmark/timer:build: �[0m �[33m@benchmark/timer:build: �[0m> @benchmark/[email protected] build /home/runner/work/astro/astro/benchmark/packages/timer �[33m@benchmark/timer:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[33m@benchmark/timer:build: �[0m �[36m@astrojs/node:build: �[0m �[36m@astrojs/node:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/node �[36m@astrojs/node:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[36m@astrojs/node:build: �[0m �[35m@astrojs/solid-js:build: �[0m �[35m@astrojs/solid-js:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/solid �[35m@astrojs/solid-js:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[35m@astrojs/solid-js:build: �[0m �[32m@astrojs/tailwind:build: �[0mcache miss, executing �[2m230964f0695ccf63�[0m �[32m@astrojs/tailwind:build: �[0m �[32m@astrojs/tailwind:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/tailwind �[32m@astrojs/tailwind:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[32m@astrojs/tailwind:build: �[0m �[33m@astrojs/sitemap:build: �[0mcache miss, executing �[2mb3c7a08497f3e20e�[0m �[33m@astrojs/sitemap:build: �[0m �[33m@astrojs/sitemap:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/sitemap �[33m@astrojs/sitemap:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[33m@astrojs/sitemap:build: �[0m Tasks: 28 successful, 28 total Cached: 5 cached, 28 total Time: 1m8.859s 🦋 �[33mwarn�[39m �[31m===============================IMPORTANT!===============================�[39m 🦋 �[33mwarn�[39m Packages will be released under the next--redirects tag 🦋 �[33mwarn�[39m �[31m----------------------------------------------------------------------�[39m 🦋 �[36minfo�[39m npm info astro 🦋 �[36minfo�[39m npm info @astrojs/prism 🦋 �[36minfo�[39m npm info @astrojs/rss 🦋 �[36minfo�[39m npm info create-astro 🦋 �[36minfo�[39m npm info @astrojs/alpinejs 🦋 �[36minfo�[39m npm info @astrojs/cloudflare 🦋 �[36minfo�[39m npm info @astrojs/deno 🦋 �[36minfo�[39m npm info @astrojs/image 🦋 �[36minfo�[39m npm info @astrojs/lit 🦋 �[36minfo�[39m npm info @astrojs/markdoc 🦋 �[36minfo�[39m npm info @astrojs/mdx 🦋 �[36minfo�[39m npm info @astrojs/netlify 🦋 �[36minfo�[39m npm info @astrojs/node 🦋 �[36minfo�[39m npm info @astrojs/partytown 🦋 �[36minfo�[39m npm info @astrojs/preact 🦋 �[36minfo�[39m npm info @astrojs/prefetch 🦋 �[36minfo�[39m npm info @astrojs/react 🦋 �[36minfo�[39m npm info @astrojs/sitemap 🦋 �[36minfo�[39m npm info @astrojs/solid-js 🦋 �[36minfo�[39m npm info @astrojs/svelte 🦋 �[36minfo�[39m npm info @astrojs/tailwind 🦋 �[36minfo�[39m npm info @astrojs/turbolinks 🦋 �[36minfo�[39m npm info @astrojs/vercel 🦋 �[36minfo�[39m npm info @astrojs/vue 🦋 �[36minfo�[39m npm info @astrojs/markdown-component 🦋 �[36minfo�[39m npm info @astrojs/markdown-remark 🦋 �[36minfo�[39m npm info @astrojs/telemetry 🦋 �[36minfo�[39m npm info @astrojs/webapi 🦋 �[36minfo�[39m astro is being published because our local version (0.0.0-redirects-20230511203938) has not been published on npm 🦋 �[33mwarn�[39m @astrojs/prism is not being published because version 2.1.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/rss is not being published because version 2.4.1 is already published on npm 🦋 �[33mwarn�[39m create-astro is not being published because version 3.1.3 is already published on npm 🦋 �[33mwarn�[39m @astrojs/alpinejs is not being published because version 0.2.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/cloudflare is not being published because version 6.2.4 is already published on npm 🦋 �[33mwarn�[39m @astrojs/deno is not being published because version 4.1.0 is already published on npm 🦋 �[33mwarn�[39m @astrojs/image is not being published because version 0.16.7 is already published on npm 🦋 �[33mwarn�[39m @astrojs/lit is not being published because version 2.0.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/markdoc is not being published because version 0.1.2 is already published on npm 🦋 �[33mwarn�[39m @astrojs/mdx is not being published because version 0.19.1 is already published on npm 🦋 �[36minfo�[39m @astrojs/netlify is being published because our local version (0.0.0-redirects-20230511203938) has not been published on npm 🦋 �[33mwarn�[39m @astrojs/node is not being published because version 5.1.2 is already published on npm 🦋 �[33mwarn�[39m @astrojs/partytown is not being published because version 1.2.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/preact is not being published because version 2.1.0 is already published on npm 🦋 �[33mwarn�[39m @astrojs/prefetch is not being published because version 0.2.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/react is not being published because version 2.1.3 is already published on npm 🦋 �[36minfo�[39m @astrojs/sitemap is being published because our local version (0.0.0-redirects-20230511203938) has not been published on npm 🦋 �[33mwarn�[39m @astrojs/solid-js is not being published because version 2.1.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/svelte is not being published because version 2.1.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/tailwind is not being published because version 3.1.2 is already published on npm 🦋 �[33mwarn�[39m @astrojs/turbolinks is not being published because version 0.2.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/vercel is not being published because version 3.3.0 is already published on npm 🦋 �[33mwarn�[39m @astrojs/vue is not being published because version 2.1.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/markdown-component is not being published because version 1.0.3 is already published on npm 🦋 �[33mwarn�[39m @astrojs/markdown-remark is not being published because version 2.2.0 is already published on npm 🦋 �[33mwarn�[39m @astrojs/telemetry is not being published because version 2.1.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/webapi is not being published because version 2.1.1 is already published on npm 🦋 �[36minfo�[39m Publishing �[36m"astro"�[39m at �[32m"0.0.0-redirects-20230511203938"�[39m 🦋 �[36minfo�[39m Publishing �[36m"@astrojs/netlify"�[39m at �[32m"0.0.0-redirects-20230511203938"�[39m 🦋 �[36minfo�[39m Publishing �[36m"@astrojs/sitemap"�[39m at �[32m"0.0.0-redirects-20230511203938"�[39m 🦋 �[32msuccess�[39m packages published successfully: 🦋 [email protected] 🦋 @astrojs/[email protected] 🦋 @astrojs/[email protected] 🦋 Creating git tags... 🦋 New tag: [email protected] 🦋 New tag: @astrojs/[email protected] 🦋 New tag: @astrojs/[email protected]

@matthewp
Copy link
Contributor Author

!preview redirects

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some docs comments, for your consideration @matthewp!

packages/astro/src/@types/astro.ts Outdated Show resolved Hide resolved
packages/astro/src/@types/astro.ts Outdated Show resolved Hide resolved
packages/astro/src/@types/astro.ts Outdated Show resolved Hide resolved
github-actions[bot]

This comment was marked as duplicate.

github-actions[bot]

This comment was marked as duplicate.

github-actions[bot]

This comment was marked as duplicate.

github-actions[bot]

This comment was marked as duplicate.

github-actions[bot]

This comment was marked as duplicate.

github-actions[bot]

This comment was marked as duplicate.

github-actions[bot]

This comment was marked as duplicate.

github-actions[bot]

This comment was marked as duplicate.

Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, excited for this feature!

@matthewp matthewp merged commit 57f8d14 into main Jun 5, 2023
15 checks passed
@matthewp matthewp deleted the redirects-ssg branch June 5, 2023 13:03
@astrobot-houston astrobot-houston mentioned this pull request Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants