Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
126 changes: 126 additions & 0 deletions .github/workflows/check-redirects.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Check Redirects for Deleted Pages

on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- "app/**/*.md"
- "app/**/*.mdx"
- "next.config.ts"

permissions:
contents: read
pull-requests: write

jobs:
check-redirects:
name: Verify Deleted Pages Have Redirects
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history needed for branch comparison

- name: Fetch base branch
run: git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}

- name: Check for missing redirects
id: check
run: |
chmod +x ./scripts/check-redirects.sh
./scripts/check-redirects.sh ${{ github.base_ref }} 2>&1 | tee redirect-check-output.txt
continue-on-error: true

- name: Comment on PR if redirects are missing
if: failure() || steps.check.outcome == 'failure'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const output = fs.readFileSync('redirect-check-output.txt', 'utf8');

// Extract the missing redirects and suggestions from output
const body = `## 🔗 Missing Redirects Detected

This PR deletes markdown files that don't have corresponding redirects in \`next.config.ts\`.

When you delete a page, you must add a redirect to prevent broken links for users who have bookmarked the old URL.

<details>
<summary>📋 View Details</summary>

\`\`\`
${output}
\`\`\`

</details>

### How to fix

1. Open \`next.config.ts\`
2. Find the \`redirects()\` function
3. Add redirect entries for each deleted file (see suggestions above)
4. Push the changes

---
*This check ensures we maintain URL stability for our documentation.*`;

// Check if we already commented
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});

const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('Missing Redirects Detected')
);

if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
}

- name: Remove outdated comment if check passes
if: steps.check.outcome == 'success'
uses: actions/github-script@v7
with:
script: |
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});

const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('Missing Redirects Detected')
);

if (botComment) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
});
}

- name: Fail if redirects are missing
if: steps.check.outcome == 'failure'
run: |
echo "❌ Missing redirects for deleted pages. See PR comment for details."
exit 1
3 changes: 0 additions & 3 deletions app/en/guides/_meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ export const meta: MetaRecord = {
"create-tools": {
title: "Create tools",
},
"agent-frameworks": {
title: "Agent frameworks",
},
"user-facing-agents": {
title: "User-facing agents",
},
Expand Down
3 changes: 0 additions & 3 deletions app/en/guides/tool-calling/_meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ export const meta: MetaRecord = {
"call-third-party-apis": {
title: "Call third-party APIs",
},
"mcp-clients": {
title: "Connect to MCP clients",
},
"custom-apps": {
title: "In custom applications",
},
Expand Down
22 changes: 22 additions & 0 deletions next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,28 @@ const nextConfig: NextConfig = withLlmsTxt({
destination: "/:locale/guides/create-tools/:path*",
permanent: true,
},
// Agent frameworks moved from guides to get-started
{
source: "/:locale/guides/agent-frameworks",
destination: "/:locale/get-started/agent-frameworks",
permanent: true,
},
{
source: "/:locale/guides/agent-frameworks/:path*",
destination: "/:locale/get-started/agent-frameworks/:path*",
permanent: true,
},
// MCP clients moved from guides/tool-calling to get-started
{
source: "/:locale/guides/tool-calling/mcp-clients",
destination: "/:locale/get-started/mcp-clients",
permanent: true,
},
{
source: "/:locale/guides/tool-calling/mcp-clients/:path*",
destination: "/:locale/get-started/mcp-clients/:path*",
permanent: true,
},
];
},
headers: async () => [
Expand Down
Loading
Loading