Skip to content

Commit 0821705

Browse files
authored
Rename 'short-title' page metadata to 'shortTitle' (#6870)
This updates the Dart docs site to align with the naming on the Flutter docs site.
1 parent fc79ac7 commit 0821705

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+86
-84
lines changed

site/lib/_sass/components/_breadcrumbs.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ nav.breadcrumbs {
3939
}
4040
}
4141

42-
.child-icon {
42+
.material-symbols {
4343
user-select: none;
4444
}
4545
}

site/lib/src/components/breadcrumbs.dart

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import 'package:collection/collection.dart';
66
import 'package:jaspr/jaspr.dart';
77
import 'package:jaspr_content/jaspr_content.dart';
88

9+
import 'material_icon.dart';
10+
911
/// Breadcrumbs navigation component that
1012
/// follows ARIA guidelines and includes RDFa markup.
1113
///
@@ -49,18 +51,15 @@ class PageBreadcrumbs extends StatelessComponent {
4951
/// Extract breadcrumbs from page data.
5052
///
5153
/// Uses page metadata to generate breadcrumb titles with fallbacks:
52-
/// breadcrumb >short-title > title.
54+
/// `breadcrumb` > `shortTitle` > `title`.
5355
List<_BreadcrumbItem>? _breadcrumbsForPage(List<Page> pages, Page page) {
5456
final pageUrl = page.url;
5557

5658
// Only show breadcrumbs if the URL isn't empty.
5759
if (pageUrl.isEmpty || pageUrl == '/') return null;
5860

59-
final pageData = page.data.page;
60-
61-
final displayTitle =
62-
pageData['breadcrumb'] ?? pageData['short-title'] ?? pageData['title'];
63-
if (displayTitle is! String || displayTitle.isEmpty) {
61+
final pageBreadcrumb = page.breadcrumb;
62+
if (pageBreadcrumb == null) {
6463
return null;
6564
}
6665

@@ -85,15 +84,10 @@ class PageBreadcrumbs extends StatelessComponent {
8584
// Skip if no index page found.
8685
if (indexPage == null) continue;
8786

88-
final indexPageData = indexPage.data.page;
89-
final indexTitle =
90-
indexPageData['breadcrumb'] ??
91-
indexPageData['short-title'] ??
92-
indexPageData['title'];
93-
if (indexTitle is String && indexTitle.isNotEmpty) {
87+
if (indexPage.breadcrumb case final indexBreadcrumb?) {
9488
breadcrumbs.add(
9589
_BreadcrumbItem(
96-
title: indexTitle,
90+
title: indexBreadcrumb,
9791
url: indexPage.url,
9892
),
9993
);
@@ -109,7 +103,7 @@ class PageBreadcrumbs extends StatelessComponent {
109103
// Add the current page as the final breadcrumb.
110104
breadcrumbs.add(
111105
_BreadcrumbItem(
112-
title: displayTitle,
106+
title: pageBreadcrumb,
113107
url: pageUrl,
114108
),
115109
);
@@ -118,6 +112,19 @@ class PageBreadcrumbs extends StatelessComponent {
118112
}
119113
}
120114

115+
extension on Page {
116+
String? get breadcrumb {
117+
final pageData = data.page;
118+
119+
final breadcrumbString =
120+
pageData['breadcrumb'] ?? pageData['shortTitle'] ?? pageData['title'];
121+
if (breadcrumbString is! String || breadcrumbString.isEmpty) {
122+
return null;
123+
}
124+
return breadcrumbString;
125+
}
126+
}
127+
121128
final class _BreadcrumbItem {
122129
const _BreadcrumbItem({required this.title, required this.url});
123130

@@ -157,12 +164,7 @@ final class _BreadcrumbItemComponent extends StatelessComponent {
157164
],
158165
),
159166
meta(attributes: {'property': 'position', 'content': index.toString()}),
160-
if (!isLast)
161-
span(
162-
classes: 'material-symbols child-icon',
163-
attributes: {'aria-hidden': 'true'},
164-
[text('chevron_right')],
165-
),
167+
if (!isLast) const MaterialIcon('chevron_right'),
166168
],
167169
);
168170
}

src/content/community/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Community and support
3-
short-title: Community
3+
shortTitle: Community
44
description: Communities, mailing lists, and bug databases for the Dart project.
55
group: https://groups.google.com/a/dartlang.org
66
---

src/content/get-dart/archive/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Dart SDK archive
3-
short-title: Archive
3+
shortTitle: Archive
44
description: >-
55
Download specific stable, beta, dev, and main channel versions of
66
the Dart SDK and the Dart API documentation.

src/content/get-dart/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Get the Dart SDK
3-
short-title: Get Dart
3+
shortTitle: Get Dart
44
description: >-
55
Get the libraries and command-line tools that you need to develop
66
Dart web, command-line, and server apps.

src/content/get-started/add-commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Make your CLI program interactive
3-
short-title: Add commands
3+
shortTitle: Add commands
44
description: >-
55
Add simple commands to your cli application. Learn the fundamentals of Dart
66
syntax including control flow, collections, variables, functions, and more.

src/content/get-started/advanced-oop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Advanced OOP-adjacent features
3-
short-title: Advanced OOP Features
3+
shortTitle: Advanced OOP Features
44
description: >-
55
Enhance your Dart skills by exploring advanced features like enhanced enums
66
and extensions. Improve your application's output formatting and color,

src/content/get-started/async.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Intro to async and HTTP
3-
short-title: Async and HTTP
3+
shortTitle: Async and HTTP
44
description: >-
55
Learn about asynchronous programming in Dart and how to make HTTP requests.
66
sitemap: false

src/content/get-started/command-runner-polish.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Command_runner polish
3-
short-title: Command_runner polish
3+
shortTitle: Command_runner polish
44
description: >-
55
Improve the HelpCommand to provide more detailed information and add an
66
onOutput argument for flexible output handling.

src/content/get-started/error-handling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Error handling
3-
short-title: Error handling
3+
shortTitle: Error handling
44
description: >-
55
Improve app robustness by handling errors. Learn about exceptions, errors,
66
`try/catch`, `throw`, and `rethrow`.

0 commit comments

Comments
 (0)