Skip to content

Commit bf943ee

Browse files
committed
Ensure that description is not displayed on each page when specified globally
Fixes #2286
1 parent d3fd824 commit bf943ee

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

news/changelog-1.2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
## Books
3838

3939
- Fix issue that caused incomplete search indexes for books
40+
- Don't display the book description in each chapter's title block
4041

4142
## Publishing
4243

src/config/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ export const kDoi = "doi";
414414
export const kAbstract = "abstract";
415415
export const kAbstractTitle = "abstract-title";
416416
export const kDescription = "description";
417+
export const kHideDescription = "hide-description";
417418
export const kTocTitle = "toc-title";
418419
export const kTocLocation = "toc-location";
419420
export const kLang = "lang";

src/project/types/book/book-render.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
kDate,
2323
kDescription,
2424
kDoi,
25+
kHideDescription,
2526
kNumberSections,
2627
kOutputExt,
2728
kOutputFile,
@@ -87,6 +88,7 @@ import { removePandocTo } from "../../../command/render/flags.ts";
8788
import { resourcePath } from "../../../core/resources.ts";
8889
import { PandocAttr, PartitionedMarkdown } from "../../../core/pandoc/types.ts";
8990
import { stringify } from "encoding/yaml.ts";
91+
import { fromFileUrl } from "https://deno.land/[email protected]/path/win32.ts";
9092

9193
export function bookPandocRenderer(
9294
options: RenderOptions,
@@ -169,6 +171,9 @@ export function bookPandocRenderer(
169171
? chapterInfoForInput(project, fileRelative)
170172
: undefined;
171173

174+
// Since this is a book page, we need to suppress rendering of the description
175+
file.recipe.format.metadata[kHideDescription] = true;
176+
172177
// see if there is a 'title' in the yaml, if there isn't one, then we
173178
// try to extract via partitioned.headingText
174179
const titleInMetadata = frontMatterTitle(partitioned.yaml);

src/resources/formats/html/templates/title-block.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ <h1 class="title">$title$</h1>
1515
$endif$
1616
</div>
1717

18-
$if(description)$
18+
$if(hide-description)$
19+
$elseif(description)$
1920
<div>
2021
<div class="description">
2122
$description$

0 commit comments

Comments
 (0)