Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
82 changes: 0 additions & 82 deletions dev/rss.js

This file was deleted.

2 changes: 0 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const {withContentlayer} = require('next-contentlayer');
const {generateRssFeed} = require('./dev/rss');
const {execSync} = require('child_process');
/** @type {import('next').NextConfig} */

Expand All @@ -24,6 +23,5 @@ module.exports = async () => {
execSync('node dev/check-links.mjs', {stdio: 'inherit'});
execSync('node dev/check-filenames.mjs', {stdio: 'inherit'});
execSync('node dev/check-images.mjs', {stdio: 'inherit'});
await generateRssFeed();
return withContentlayer(nextConfig);
};
3 changes: 2 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Providers} from '@/app/providers';
import {Layout} from '@/components/Layout';
import {TECHNICAL_CHANGELOG_RSS_URL} from '@/data/constants';
import {GoogleAnalytics} from '@next/third-parties/google';
import clsx from 'clsx';
import config from 'docs.config';
Expand Down Expand Up @@ -81,7 +82,7 @@ export default function RootLayout({children}: {children: React.ReactNode}) {
rel="alternate"
type="application/rss+xml"
title="RSS Feed for Sourcegraph"
href="/technical-changelog.rss"
href={TECHNICAL_CHANGELOG_RSS_URL}
/>
</head>
<body
Expand Down
7 changes: 7 additions & 0 deletions src/data/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* URL for the technical changelog RSS feed.
* Generated by the new docs service at:
* https://github.com/sourcegraph/sourcegraph/blob/main/cmd/docs/src/routes/changelog/technical-changelog.rss/%2Bserver.ts
*/
export const TECHNICAL_CHANGELOG_RSS_URL =
'https://sourcegraph.com/changelog/technical-changelog.rss';
9 changes: 9 additions & 0 deletions src/data/redirects.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {TECHNICAL_CHANGELOG_RSS_URL} from './constants';

const redirectsData = [
{
source: '/integration/img/disable_extension.png',
Expand Down Expand Up @@ -7069,6 +7071,13 @@ const redirectsData = [
source: '/admin/repo/permissions',
destination: '/admin/permissions',
permanent: true
},
// RSS feed moved from /docs/technical-changelog.rss to /changelog/technical-changelog.rss
// This redirect preserves existing RSS subscriptions
{
source: '/technical-changelog.rss',
destination: TECHNICAL_CHANGELOG_RSS_URL,
permanent: true
}
];

Expand Down
9 changes: 5 additions & 4 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import type {NextRequest} from 'next/server';
import {NextResponse} from 'next/server';
import docsConfig from '../docs.config.js';

import {TECHNICAL_CHANGELOG_RSS_URL} from './data/constants';

const {updatedRedirectsData} = require('./data/redirects.ts');

function createRedirectUrl(
Expand Down Expand Up @@ -71,7 +73,8 @@ export function middleware(request: NextRequest) {
);
if (redirect) {
return NextResponse.redirect(
createRedirectUrl(request, redirect.destination, path)
createRedirectUrl(request, redirect.destination, path),
redirect.permanent ? 308 : 307

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

permanent redirects are basically impossible to ever change again because of very aggressive browser caching, maybe we should just keep them as 307s? there are a lot of permanent ones in the redirects and I'm not convinced we want all of them to redirect for all time going forward 😬

);
}

Expand Down Expand Up @@ -138,9 +141,7 @@ export function middleware(request: NextRequest) {
}

if (pathWithoutBase === '/changelog.rss')
return NextResponse.redirect(
createRedirectUrl(request, '/technical-changelog.rss', path)
);
return NextResponse.redirect(TECHNICAL_CHANGELOG_RSS_URL, 308);

return NextResponse.next();
}
Expand Down