Skip to content

Commit 427c3dd

Browse files
committed
Correctly resolve date from from command line flag
Fixes #2794 again
1 parent bbe4309 commit 427c3dd

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/command/render/render-files.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,19 @@ export async function renderFiles(
357357
// Set the date locale for this render
358358
// Used for date formatting
359359
initDayJsPlugins();
360-
if (
361-
context.format.metadata[kLang] &&
362-
typeof (context.format.metadata[kLang]) === "string"
363-
) {
360+
const resolveLang = () => {
361+
const lang = context.format.metadata[kLang] ||
362+
options.flags?.pandocMetadata?.[kLang];
363+
if (typeof (lang) === "string") {
364+
return lang;
365+
} else {
366+
return undefined;
367+
}
368+
};
369+
const dateFormatLang = resolveLang();
370+
if (dateFormatLang) {
364371
await setDateLocale(
365-
options.flags?.pandocMetadata?.[kLang] as string ||
366-
context.format.metadata[kLang] as string,
372+
dateFormatLang,
367373
);
368374
}
369375

0 commit comments

Comments
 (0)