Skip to content

Commit bdc075a

Browse files
authored
[Bug] Handle double quotes in sidebar_label frontmatter (#338)
* Replace single with double quotes in title * Wrap sidebar_label in double qutoes
1 parent 0fd44b5 commit bdc075a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

packages/docusaurus-plugin-openapi-docs/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ description: "{{{frontMatter.description}}}"
164164
sidebar_label: Introduction
165165
{{/api}}
166166
{{#api}}
167-
sidebar_label: {{{title}}}
167+
sidebar_label: "{{{title}}}"
168168
{{/api}}
169169
{{^api}}
170170
sidebar_position: 0
@@ -191,7 +191,7 @@ info_path: {{{infoPath}}}
191191
id: {{{id}}}
192192
title: "{{{title}}}"
193193
description: "{{{frontMatter.description}}}"
194-
sidebar_label: {{{title}}}
194+
sidebar_label: "{{{title}}}"
195195
hide_title: true
196196
custom_edit_url: null
197197
---

packages/docusaurus-plugin-openapi-docs/src/openapi/openapi.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ function createItems(
131131
type: "info",
132132
id: infoId,
133133
unversionedId: infoId,
134-
title: openapiData.info.title,
134+
title: openapiData.info.title
135+
? openapiData.info.title.replace(/((?:^|[^\\])(?:\\{2})*)"/g, "$1'")
136+
: "",
135137
description: openapiData.info.description
136138
? openapiData.info.description.replace(
137139
/((?:^|[^\\])(?:\\{2})*)"/g,
@@ -237,7 +239,7 @@ function createItems(
237239
id: baseId,
238240
infoId: infoId ?? "",
239241
unversionedId: baseId,
240-
title: title,
242+
title: title ? title.replace(/((?:^|[^\\])(?:\\{2})*)"/g, "$1'") : "",
241243
description: operationObject.description
242244
? operationObject.description.replace(
243245
/((?:^|[^\\])(?:\\{2})*)"/g,

0 commit comments

Comments
 (0)