Skip to content

Commit 52e6bce

Browse files
authored
Include page title and description in md output (#12639)
Includes the page title and description (if present) in the secondary Markdown output for each page. **Staged example:** https://flutter-docs-prod--pr12639-feat-header-in-markdown-out-0w19b91b.web.app/ui/layout/tutorial/index.html.md
1 parent fa58364 commit 52e6bce

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

site/lib/main.dart

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,26 @@ Component get _docsFlutterDevSite => ContentApp.custom(
6464
components: _embeddableComponents,
6565
layouts: const [DocLayout(), TocLayout(), CatalogPageLayout()],
6666
theme: const ContentTheme.none(),
67-
secondaryOutputs: [const RobotsTxtOutput(), MarkdownOutput()],
67+
secondaryOutputs: [
68+
const RobotsTxtOutput(),
69+
MarkdownOutput(
70+
createHeader: (page) {
71+
final header = StringBuffer();
72+
if (page.data.page['title'] case final String title
73+
when title.isNotEmpty) {
74+
header.writeln('# $title');
75+
76+
if (page.data.page['description'] case final String description
77+
when description.isNotEmpty) {
78+
header.writeln();
79+
header.writeln('> $description');
80+
}
81+
}
82+
83+
return header.toString();
84+
},
85+
),
86+
],
6887
),
6988
);
7089

site/lib/src/components/common/tabs.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import 'package:jaspr_content/jaspr_content.dart';
88
import '../../util.dart';
99

1010
/// A tabs component where children tabs can be switched between by the user.
11-
class DashTabs implements CustomComponent {
11+
class DashTabs extends CustomComponent {
1212
static int _currentTabWrapperId = 0;
1313
static int _currentTabId = 0;
1414

15-
const DashTabs();
15+
const DashTabs() : super.base();
1616

1717
@override
1818
Component? create(Node node, NodesBuilder builder) {

site/pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ environment:
99
dependencies:
1010
build: ^4.0.2
1111
collection: ^1.19.1
12-
crypto: ^3.0.6
12+
crypto: ^3.0.7
1313
html: ^0.15.6
1414
http: ^1.5.0
1515
jaspr: ^0.21.6
16-
jaspr_content: ^0.4.2
16+
jaspr_content: ^0.4.3
1717
# Used as our template engine.
1818
liquify: ^1.3.1
1919
markdown: ^7.3.0
@@ -32,9 +32,9 @@ dev_dependencies:
3232
path: pkgs/analysis_defaults
3333
ref: f91ed8ecef6a0b31685804fe4102b25fda021460
3434
build_runner: ^2.10.1
35-
build_web_compilers: ^4.3.0
35+
build_web_compilers: ^4.4.0
3636
jaspr_builder: ^0.21.6
37-
sass: ^1.93.2
37+
sass: ^1.93.3
3838
sass_builder: ^2.4.0
3939

4040
jaspr:

0 commit comments

Comments
 (0)