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

Migrate docs site to Vercel #795

Merged
merged 23 commits into from
Nov 10, 2023
Merged

Migrate docs site to Vercel #795

merged 23 commits into from
Nov 10, 2023

Conversation

delucis
Copy link
Member

@delucis delucis commented Oct 2, 2023

What kind of changes does this PR include?

  • Something else!

Description

  • Migrates the Starlight docs to deploy to Vercel
  • Disables our lastUpdated feature, which doesn’t currently support Vercel due to them blocking deep clones
  • Adds a vercel.json with redirect config previously provided by _redirects for Netlify
  • Removes old Netlify config files. (Our _headers file was setting cache headers that are the default for Astro projects on Vercel.)
  • Will need to updated DNS after this merges

(Headers we were setting are already the default in Astro projects on Vercel.)
@changeset-bot
Copy link

changeset-bot bot commented Oct 2, 2023

⚠️ No Changeset found

Latest commit: aa0ccf8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@netlify
Copy link

netlify bot commented Oct 2, 2023

Deploy Preview for astro-starlight ready!

Name Link
🔨 Latest commit aa0ccf8
🔍 Latest deploy log https://app.netlify.com/sites/astro-starlight/deploys/654e1c672b3547000886b028
😎 Deploy Preview https://deploy-preview-795--astro-starlight.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 92 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@vercel
Copy link

vercel bot commented Oct 2, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
starlight ✅ Ready (Inspect) Visit Preview Nov 10, 2023 0:12am

@github-actions github-actions bot added the 📚 docs Documentation website changes label Oct 2, 2023
@astrobot-houston
Copy link
Collaborator

astrobot-houston commented Oct 2, 2023

size-limit report 📦

Path Size
/index.html 5.13 KB (0%)
/_astro/*.js 19.27 KB (0%)
/_astro/*.css 9.72 KB (0%)

@delucis
Copy link
Member Author

delucis commented Oct 2, 2023

Haven’t figured out the multilingual 404 support just yet. On Netlify this was pretty straightforward in _redirects:

/:lang/*    /:lang/404/   404

@HiDeoo
Copy link
Member

HiDeoo commented Oct 2, 2023

Haven’t figured out the multilingual 404 support just yet.

Could this work like rewrites with regex path matching in a Next config where to match a regex path you have wrap the regex in parenthesis after a parameter? E.g. "source": "/:lang/:useless(.*)/"?

Altho I guess this would end up being the same as :useless* 🤔

@delucis
Copy link
Member Author

delucis commented Oct 2, 2023

Yeah that’s what I tried (thanks to @tony-sull’s guidance):

  "redirects": [
    {
      "source": "/:lang/(.*)/",
      "destination": "/:lang/404/",
      "statusCode": 404
    }
  ],

The above doesn’t seem to do anything but when I tried "source": "/:lang/(.*)" (no trailing slash) it seemed to intercept requests greedily and break asset loading: https://starlight-2dm4ui5ee-astrodotbuild.vercel.app/

@delucis
Copy link
Member Author

delucis commented Oct 3, 2023

Just tried testing the deprecated routes option as suggested by the Vercel team:

{  
  "routes": [
    { "handle": "filesystem" },
    { "src": "/de/(.*)", "status": 404, "dest": "/de/404.html" }
  ]
}

But this does not work as desired, a 404 under /de/ still redirects to the root-level English 404 page: https://starlight-q01iwnobp-astrodotbuild.vercel.app/de/x/

@delucis delucis marked this pull request as draft October 3, 2023 17:13
@delucis
Copy link
Member Author

delucis commented Oct 6, 2023

Closing until we can figure out the 404 routing.

@delucis delucis closed this Oct 6, 2023
@delucis delucis reopened this Nov 9, 2023
"continue": true
},

{ "src": "/(ph$|ph/)(.*)", "dest": "https://astro-houston-ph.pages.dev/ph/$2" },
Copy link
Member Author

Choose a reason for hiding this comment

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

The regular expression here allows us to match /ph/.*, but also /ph with no trailing slash (without also accidentally matching /philosophy or something).

Tests

Comment on lines +13 to +14
{ "src": "(.*)/([^./]+)$", "dest": "$1/$2/", "status": 301 },
{ "src": "(.*)/index.html$", "dest": "$1/", "status": 301 },
Copy link
Member Author

Choose a reason for hiding this comment

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

These two rules set up similar URL normalisation to Netlify:

  1. Add a trailing slash to URLs without an extension and without a trailing slash. (Could break non-HTML files without extensions, but we don’t have any of those.)

  2. Strip index.html from the end of URLs.

These precede "handle": "filesystem" otherwise the filesystem would match and they’d never kick in.

Tests


{ "src": "/zh/(.*)", "dest": "/zh-cn/$1", "status": 301 },

{ "src": "/(?<lang>[^/]*)/(.*)", "dest": "/$lang/404/", "status": 404 }
Copy link
Member Author

Choose a reason for hiding this comment

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

@delucis delucis marked this pull request as ready for review November 9, 2023 21:14
Copy link

@tony-sull tony-sull 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!

Before merging, make sure to disconnect the Netlify builds from the github repo just in case. That will freeze Netlify on the last non-Vercel build and keep it alive until after the domain/DNS settings in Vercel take over

@delucis delucis merged commit 8e8f035 into main Nov 10, 2023
10 checks passed
@delucis delucis deleted the dx-384/vercel branch November 10, 2023 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 docs Documentation website changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants