Skip to content

Commit 312b33e

Browse files
authored
Merge pull request #33 from pkgdiff-dev/gsd/quick-261102-seo-pub-hub
fix(seo): list pub.dev packages on the pub registry page
2 parents edaf593 + 3ee6192 commit 312b33e

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

‎src/backend/PkgDiff.API/Controllers/SitemapController.cs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using Microsoft.AspNetCore.Mvc;
33
using Microsoft.Extensions.Caching.Memory;
44
using PkgDiff.Application.Interfaces;
5-
using PkgDiff.Shared.Constants;
65

76
namespace PkgDiff.API.Controllers;
87

@@ -25,6 +24,9 @@ public class SitemapController : ControllerBase
2524
"/cookies",
2625
};
2726

27+
// The values used in public URLs, where pub.dev is "pub"
28+
private static readonly string[] RegistryHubs = { "nuget", "npm", "pypi", "pub", "packagist", "maven" };
29+
2830
private readonly IAdminPackageService _adminService;
2931
private readonly IMemoryCache _memory;
3032
private readonly ILogger<SitemapController> _logger;
@@ -73,7 +75,7 @@ private async Task<string> BuildSitemapAsync()
7375
AppendUrl(xml, path, null);
7476
}
7577

76-
foreach (var registry in RegistryNames.All)
78+
foreach (var registry in RegistryHubs)
7779
{
7880
AppendUrl(xml, $"/packages?registry={registry}", null);
7981
}

‎src/frontend/public/llms.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pkgdiff helps developers decide whether a dependency upgrade is safe. It combine
1717
- [npm packages](https://pkgdiff.dev/packages?registry=npm)
1818
- [PyPI packages](https://pkgdiff.dev/packages?registry=pypi)
1919
- [Maven packages](https://pkgdiff.dev/packages?registry=maven)
20-
- [pub.dev packages](https://pkgdiff.dev/packages?registry=pub.dev)
20+
- [pub.dev packages](https://pkgdiff.dev/packages?registry=pub)
2121
- [Packagist packages](https://pkgdiff.dev/packages?registry=packagist)
2222

2323
## Package pages

‎src/frontend/src/app/features/packages/packages-list.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ const REGISTRY_LABELS: Record<string, string> = {
1515
npm: 'npm',
1616
pypi: 'PyPI',
1717
maven: 'Maven',
18-
'pub.dev': 'pub.dev',
18+
pub: 'pub.dev',
1919
packagist: 'Packagist',
2020
};
2121

2222
const REGISTRY_ALIASES: Record<string, string> = {
23-
pub: 'pub.dev',
23+
'pub.dev': 'pub',
2424
composer: 'packagist',
2525
};
2626

@@ -259,5 +259,9 @@ export class PackagesListComponent {
259259
: 'Browse packages from NuGet, npm, PyPI, Maven, pub.dev and Packagist. See version history, breaking changes and categorized release notes.',
260260
url: query ? `/packages?${query}` : '/packages',
261261
});
262+
263+
if (!this.isLoading() && this.registryPackages().length === 0) {
264+
this.seo.setNoIndex();
265+
}
262266
}
263267
}

0 commit comments

Comments
 (0)