Skip to content

Commit b1bcda4

Browse files
committed
fix: 🚑️ fix YAML stringify options
fix a bug intreoduce during refactoring of the frontmatter classes, ensure YAML is compatible with Obsidian Linter (platers/obsidian-linter#1227).
1 parent 4d5fd3b commit b1bcda4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/services/frontmatter.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { YAML_TOSTRING_OPTIONS } from 'constants/index';
12
import * as YAML from 'yaml';
23

34
/**
@@ -17,10 +18,7 @@ export class FrontmatterError extends Error {
1718
* Type definitions for Frontmatter values and data
1819
*/
1920
type PrimitiveValue = string | number | boolean | Date;
20-
type FrontmatterValue =
21-
| PrimitiveValue
22-
| Array<PrimitiveValue>
23-
| Record<string, PrimitiveValue | Array<PrimitiveValue>>;
21+
type FrontmatterValue = PrimitiveValue | Array<PrimitiveValue> | Record<string, PrimitiveValue | Array<PrimitiveValue>>;
2422
export type FrontmatterData = Record<string, FrontmatterValue>;
2523

2624
/**
@@ -44,7 +42,7 @@ export class Frontmatter {
4442
*/
4543
private validateData(data: FrontmatterData): FrontmatterData {
4644
try {
47-
const yamlString = YAML.stringify(data);
45+
const yamlString = YAML.stringify(data, YAML_TOSTRING_OPTIONS);
4846
const parsed = YAML.parse(yamlString);
4947

5048
if (typeof parsed !== 'object' || parsed === null) {
@@ -146,7 +144,9 @@ export class Frontmatter {
146144
return '';
147145
}
148146

149-
return [Frontmatter.DELIMITER, YAML.stringify(this.data).trim(), Frontmatter.DELIMITER].join('\n');
147+
return [Frontmatter.DELIMITER, YAML.stringify(this.data, YAML_TOSTRING_OPTIONS).trim(), Frontmatter.DELIMITER].join(
148+
'\n'
149+
);
150150
}
151151

152152
/**

0 commit comments

Comments
 (0)