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

[new package]: Automatic redirects from Git renames #20

Open
Fryuni opened this issue Jan 31, 2024 · 0 comments
Open

[new package]: Automatic redirects from Git renames #20

Fryuni opened this issue Jan 31, 2024 · 0 comments

Comments

@Fryuni
Copy link
Owner

Fryuni commented Jan 31, 2024

From Discord conversation

PatrickJ — Today at 10:46 AM
I'm a bit new to authoring content in markdown. I wonder how you guys ensure that redirects are made when changing slugs or folders of the content? Typically CMS can handle making those redirects but it seems a bit painful and manual with markdown. Are out there any tools that make that easier? I don't believe Astro has anything built in for it, right? I was thinking about Github action that gives heads up about changed urls?

Fryuni (Luiz Ferraz) — Today at 10:56 AM
You can get the history of renames from your git history and generate the redirects configuration
Interesting idea to publish as an integration or at least as a Starlight plugin...
git diff --stat=200 --diff-filter=R <COMMIT> src/content/<collectionName>
Will give you an output like this:

src/content/docs/ar/{core-concepts => basics}/astro-components.mdx
src/content/docs/de/{core-concepts => basics}/astro-components.mdx
src/content/docs/de/{core-concepts => basics}/astro-pages.mdx
src/content/docs/de/{core-concepts => basics}/astro-syntax.mdx
src/content/docs/de/{core-concepts => basics}/layouts.mdx

You can then parse that into and either make individual redirects or extract patterns to make a dynamic redirect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant