Skip to content

Commit

Permalink
Include the selected package tab in the page title. (dart-lang#7411)
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos authored Jan 19, 2024
1 parent bef2edd commit aa7cec0
Show file tree
Hide file tree
Showing 25 changed files with 69 additions and 51 deletions.
24 changes: 21 additions & 3 deletions app/lib/frontend/templates/package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,18 @@ String renderPkgScorePage(PackagePageData data) {
);
}

final _pagetTitleTabIdentifiers = <urls.PkgPageTab, String>{
urls.PkgPageTab.changelog: 'changelog',
urls.PkgPageTab.example: 'example',
urls.PkgPageTab.install: 'install',
urls.PkgPageTab.license: 'license',
urls.PkgPageTab.score: 'score',
urls.PkgPageTab.pubspec: 'pubspec',
urls.PkgPageTab.admin: 'admin',
urls.PkgPageTab.activityLog: 'activity log',
urls.PkgPageTab.versions: 'versions',
};

String _renderPkgPage({
required PackagePageData data,
required List<Tab> tabs,
Expand All @@ -245,10 +257,16 @@ String _renderPkgPage({

final isFlutterPackage = data.version.pubspec!.usesFlutter;
final packageAndVersion = data.isLatestStable
? data.package.name
? data.package.name!
: '${data.package.name} ${data.version.version}';
final pageTitle =
'$packageAndVersion | ${isFlutterPackage ? 'Flutter' : 'Dart'} Package';
final pageTitleTabIdentifier = _pagetTitleTabIdentifiers[pkgPageTab];
final pageTitle = <String>[
packageAndVersion,
if (pageTitleTabIdentifier != null) pageTitleTabIdentifier,
'|',
isFlutterPackage ? 'Flutter' : 'Dart',
'package',
].join(' ');
final canonicalUrl = urls.pkgPageUrl(
data.package.name!,
version: data.isLatestStable ? null : data.version.version,
Expand Down
4 changes: 2 additions & 2 deletions app/test/frontend/golden/pkg_changelog_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<meta name="twitter:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="Dart packages"/>
<meta property="og:title" content="oxygen | Dart Package"/>
<meta property="og:title" content="oxygen changelog | Dart package"/>
<meta property="og:description" content="oxygen is awesome"/>
<meta property="og:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<title>oxygen | Dart Package</title>
<title>oxygen changelog | Dart package</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&amp;family=Google+Sans+Display:wght@400&amp;family=Google+Sans+Text:wght@400;500;700&amp;family=Google+Sans+Mono:wght@400;700&amp;display=swap"/>
<link rel="shortcut icon" href="/favicon.ico?hash=mocked_hash_985685822"/>
<link rel="stylesheet" href="https://www.gstatic.com/glue/v25_0/ccb.min.css"/>
Expand Down
4 changes: 2 additions & 2 deletions app/test/frontend/golden/pkg_example_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<meta name="twitter:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="Dart packages"/>
<meta property="og:title" content="oxygen | Dart Package"/>
<meta property="og:title" content="oxygen example | Dart package"/>
<meta property="og:description" content="oxygen is awesome"/>
<meta property="og:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<title>oxygen | Dart Package</title>
<title>oxygen example | Dart package</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&amp;family=Google+Sans+Display:wght@400&amp;family=Google+Sans+Text:wght@400;500;700&amp;family=Google+Sans+Mono:wght@400;700&amp;display=swap"/>
<link rel="shortcut icon" href="/favicon.ico?hash=mocked_hash_985685822"/>
<link rel="stylesheet" href="https://www.gstatic.com/glue/v25_0/ccb.min.css"/>
Expand Down
4 changes: 2 additions & 2 deletions app/test/frontend/golden/pkg_install_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<meta name="twitter:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="Dart packages"/>
<meta property="og:title" content="oxygen | Dart Package"/>
<meta property="og:title" content="oxygen install | Dart package"/>
<meta property="og:description" content="oxygen is awesome"/>
<meta property="og:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<title>oxygen | Dart Package</title>
<title>oxygen install | Dart package</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&amp;family=Google+Sans+Display:wght@400&amp;family=Google+Sans+Text:wght@400;500;700&amp;family=Google+Sans+Mono:wght@400;700&amp;display=swap"/>
<link rel="shortcut icon" href="/favicon.ico?hash=mocked_hash_985685822"/>
<link rel="stylesheet" href="https://www.gstatic.com/glue/v25_0/ccb.min.css"/>
Expand Down
4 changes: 2 additions & 2 deletions app/test/frontend/golden/pkg_score_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<meta name="twitter:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="Dart packages"/>
<meta property="og:title" content="oxygen | Dart Package"/>
<meta property="og:title" content="oxygen score | Dart package"/>
<meta property="og:description" content="oxygen is awesome"/>
<meta property="og:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<title>oxygen | Dart Package</title>
<title>oxygen score | Dart package</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&amp;family=Google+Sans+Display:wght@400&amp;family=Google+Sans+Text:wght@400;500;700&amp;family=Google+Sans+Mono:wght@400;700&amp;display=swap"/>
<link rel="shortcut icon" href="/favicon.ico?hash=mocked_hash_985685822"/>
<link rel="stylesheet" href="https://www.gstatic.com/glue/v25_0/ccb.min.css"/>
Expand Down
4 changes: 2 additions & 2 deletions app/test/frontend/golden/pkg_show_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<meta name="twitter:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="Dart packages"/>
<meta property="og:title" content="oxygen | Dart Package"/>
<meta property="og:title" content="oxygen | Dart package"/>
<meta property="og:description" content="oxygen is awesome"/>
<meta property="og:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<title>oxygen | Dart Package</title>
<title>oxygen | Dart package</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&amp;family=Google+Sans+Display:wght@400&amp;family=Google+Sans+Text:wght@400;500;700&amp;family=Google+Sans+Mono:wght@400;700&amp;display=swap"/>
<link rel="shortcut icon" href="/favicon.ico?hash=mocked_hash_985685822"/>
<link rel="stylesheet" href="https://www.gstatic.com/glue/v25_0/ccb.min.css"/>
Expand Down
4 changes: 2 additions & 2 deletions app/test/frontend/golden/pkg_show_page_discontinued.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<meta name="twitter:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="Dart packages"/>
<meta property="og:title" content="pkg | Dart Package"/>
<meta property="og:title" content="pkg | Dart package"/>
<meta property="og:description" content="pkg is awesome"/>
<meta property="og:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<title>pkg | Dart Package</title>
<title>pkg | Dart package</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&amp;family=Google+Sans+Display:wght@400&amp;family=Google+Sans+Text:wght@400;500;700&amp;family=Google+Sans+Mono:wght@400;700&amp;display=swap"/>
<link rel="shortcut icon" href="/favicon.ico?hash=mocked_hash_985685822"/>
<link rel="stylesheet" href="https://www.gstatic.com/glue/v25_0/ccb.min.css"/>
Expand Down
4 changes: 2 additions & 2 deletions app/test/frontend/golden/pkg_show_page_flutter_plugin.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<meta name="twitter:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="Dart packages"/>
<meta property="og:title" content="flutter_titanium | Flutter Package"/>
<meta property="og:title" content="flutter_titanium | Flutter package"/>
<meta property="og:description" content="flutter_titanium is awesome"/>
<meta property="og:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<title>flutter_titanium | Flutter Package</title>
<title>flutter_titanium | Flutter package</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&amp;family=Google+Sans+Display:wght@400&amp;family=Google+Sans+Text:wght@400;500;700&amp;family=Google+Sans+Mono:wght@400;700&amp;display=swap"/>
<link rel="shortcut icon" href="/static/hash-%%etag%%/img/flutter-logo-32x32.png"/>
<link rel="stylesheet" href="https://www.gstatic.com/glue/v25_0/ccb.min.css"/>
Expand Down
4 changes: 2 additions & 2 deletions app/test/frontend/golden/pkg_show_page_publisher.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<meta name="twitter:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="Dart packages"/>
<meta property="og:title" content="neon | Dart Package"/>
<meta property="og:title" content="neon | Dart package"/>
<meta property="og:description" content="neon is awesome"/>
<meta property="og:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<title>neon | Dart Package</title>
<title>neon | Dart package</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&amp;family=Google+Sans+Display:wght@400&amp;family=Google+Sans+Text:wght@400;500;700&amp;family=Google+Sans+Mono:wght@400;700&amp;display=swap"/>
<link rel="shortcut icon" href="/favicon.ico?hash=mocked_hash_985685822"/>
<link rel="stylesheet" href="https://www.gstatic.com/glue/v25_0/ccb.min.css"/>
Expand Down
4 changes: 2 additions & 2 deletions app/test/frontend/golden/pkg_show_page_retracted.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<meta name="twitter:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="Dart packages"/>
<meta property="og:title" content="pkg 1.0.0 | Dart Package"/>
<meta property="og:title" content="pkg 1.0.0 | Dart package"/>
<meta property="og:description" content="pkg is awesome"/>
<meta property="og:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<title>pkg 1.0.0 | Dart Package</title>
<title>pkg 1.0.0 | Dart package</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&amp;family=Google+Sans+Display:wght@400&amp;family=Google+Sans+Text:wght@400;500;700&amp;family=Google+Sans+Mono:wght@400;700&amp;display=swap"/>
<link rel="shortcut icon" href="/favicon.ico?hash=mocked_hash_985685822"/>
<link rel="stylesheet" href="https://www.gstatic.com/glue/v25_0/ccb.min.css"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<meta name="twitter:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="Dart packages"/>
<meta property="og:title" content="pkg | Dart Package"/>
<meta property="og:title" content="pkg | Dart package"/>
<meta property="og:description" content="pkg is awesome"/>
<meta property="og:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<title>pkg | Dart Package</title>
<title>pkg | Dart package</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&amp;family=Google+Sans+Display:wght@400&amp;family=Google+Sans+Text:wght@400;500;700&amp;family=Google+Sans+Mono:wght@400;700&amp;display=swap"/>
<link rel="shortcut icon" href="/favicon.ico?hash=mocked_hash_985685822"/>
<link rel="stylesheet" href="https://www.gstatic.com/glue/v25_0/ccb.min.css"/>
Expand Down
4 changes: 2 additions & 2 deletions app/test/frontend/golden/pkg_show_version_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<meta name="twitter:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="Dart packages"/>
<meta property="og:title" content="oxygen | Dart Package"/>
<meta property="og:title" content="oxygen | Dart package"/>
<meta property="og:description" content="oxygen is awesome"/>
<meta property="og:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<title>oxygen | Dart Package</title>
<title>oxygen | Dart package</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&amp;family=Google+Sans+Display:wght@400&amp;family=Google+Sans+Text:wght@400;500;700&amp;family=Google+Sans+Mono:wght@400;700&amp;display=swap"/>
<link rel="shortcut icon" href="/favicon.ico?hash=mocked_hash_985685822"/>
<link rel="stylesheet" href="https://www.gstatic.com/glue/v25_0/ccb.min.css"/>
Expand Down
4 changes: 2 additions & 2 deletions app/test/task/testdata/goldens/packages/oxygen.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<meta name="twitter:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="Dart packages"/>
<meta property="og:title" content="oxygen | Dart Package"/>
<meta property="og:title" content="oxygen | Dart package"/>
<meta property="og:description" content="oxygen is awesome"/>
<meta property="og:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<title>oxygen | Dart Package</title>
<title>oxygen | Dart package</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&amp;family=Google+Sans+Display:wght@400&amp;family=Google+Sans+Text:wght@400;500;700&amp;family=Google+Sans+Mono:wght@400;700&amp;display=swap"/>
<link rel="shortcut icon" href="/favicon.ico?hash=mocked_hash_985685822"/>
<link rel="stylesheet" href="https://www.gstatic.com/glue/v25_0/ccb.min.css"/>
Expand Down
4 changes: 2 additions & 2 deletions app/test/task/testdata/goldens/packages/oxygen/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<meta name="twitter:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="Dart packages"/>
<meta property="og:title" content="oxygen | Dart Package"/>
<meta property="og:title" content="oxygen changelog | Dart package"/>
<meta property="og:description" content="oxygen is awesome"/>
<meta property="og:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<title>oxygen | Dart Package</title>
<title>oxygen changelog | Dart package</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&amp;family=Google+Sans+Display:wght@400&amp;family=Google+Sans+Text:wght@400;500;700&amp;family=Google+Sans+Mono:wght@400;700&amp;display=swap"/>
<link rel="shortcut icon" href="/favicon.ico?hash=mocked_hash_985685822"/>
<link rel="stylesheet" href="https://www.gstatic.com/glue/v25_0/ccb.min.css"/>
Expand Down
4 changes: 2 additions & 2 deletions app/test/task/testdata/goldens/packages/oxygen/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<meta name="twitter:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="Dart packages"/>
<meta property="og:title" content="oxygen | Dart Package"/>
<meta property="og:title" content="oxygen example | Dart package"/>
<meta property="og:description" content="oxygen is awesome"/>
<meta property="og:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<title>oxygen | Dart Package</title>
<title>oxygen example | Dart package</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&amp;family=Google+Sans+Display:wght@400&amp;family=Google+Sans+Text:wght@400;500;700&amp;family=Google+Sans+Mono:wght@400;700&amp;display=swap"/>
<link rel="shortcut icon" href="/favicon.ico?hash=mocked_hash_985685822"/>
<link rel="stylesheet" href="https://www.gstatic.com/glue/v25_0/ccb.min.css"/>
Expand Down
4 changes: 2 additions & 2 deletions app/test/task/testdata/goldens/packages/oxygen/install.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<meta name="twitter:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="Dart packages"/>
<meta property="og:title" content="oxygen | Dart Package"/>
<meta property="og:title" content="oxygen install | Dart package"/>
<meta property="og:description" content="oxygen is awesome"/>
<meta property="og:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<title>oxygen | Dart Package</title>
<title>oxygen install | Dart package</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&amp;family=Google+Sans+Display:wght@400&amp;family=Google+Sans+Text:wght@400;500;700&amp;family=Google+Sans+Mono:wght@400;700&amp;display=swap"/>
<link rel="shortcut icon" href="/favicon.ico?hash=mocked_hash_985685822"/>
<link rel="stylesheet" href="https://www.gstatic.com/glue/v25_0/ccb.min.css"/>
Expand Down
4 changes: 2 additions & 2 deletions app/test/task/testdata/goldens/packages/oxygen/license.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<meta name="twitter:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="Dart packages"/>
<meta property="og:title" content="oxygen | Dart Package"/>
<meta property="og:title" content="oxygen license | Dart package"/>
<meta property="og:description" content="oxygen is awesome"/>
<meta property="og:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<title>oxygen | Dart Package</title>
<title>oxygen license | Dart package</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&amp;family=Google+Sans+Display:wght@400&amp;family=Google+Sans+Text:wght@400;500;700&amp;family=Google+Sans+Mono:wght@400;700&amp;display=swap"/>
<link rel="shortcut icon" href="/favicon.ico?hash=mocked_hash_985685822"/>
<link rel="stylesheet" href="https://www.gstatic.com/glue/v25_0/ccb.min.css"/>
Expand Down
4 changes: 2 additions & 2 deletions app/test/task/testdata/goldens/packages/oxygen/score.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<meta name="twitter:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="Dart packages"/>
<meta property="og:title" content="oxygen | Dart Package"/>
<meta property="og:title" content="oxygen score | Dart package"/>
<meta property="og:description" content="oxygen is awesome"/>
<meta property="og:image" content="https://pub.dev/static/hash-%%etag%%/img/pub-dev-icon-cover-image.png"/>
<title>oxygen | Dart Package</title>
<title>oxygen score | Dart package</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&amp;family=Google+Sans+Display:wght@400&amp;family=Google+Sans+Text:wght@400;500;700&amp;family=Google+Sans+Mono:wght@400;700&amp;display=swap"/>
<link rel="shortcut icon" href="/favicon.ico?hash=mocked_hash_985685822"/>
<link rel="stylesheet" href="https://www.gstatic.com/glue/v25_0/ccb.min.css"/>
Expand Down
Loading

0 comments on commit aa7cec0

Please sign in to comment.