一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
23 行
732 B
TypeScript
23 行
732 B
TypeScript
/* eslint-disable import/prefer-default-export */
|
|
|
|
import { FrontMatter } from './frontMatter';
|
|
import { basename } from 'path';
|
|
import moment from 'moment';
|
|
|
|
export const getNewsDateString = (info: FrontMatter, mdFilePath: string): string => {
|
|
return moment(getNewsDate(info, mdFilePath)).format('D MMM YYYY');
|
|
};
|
|
|
|
export const getNewsDate = (info: FrontMatter, mdFilePath: string): Date => {
|
|
// If the date is set in the metadata, we get it from there. Otherwise we
|
|
// derive it from the filename (eg. 20220224-release-2-7.md)
|
|
|
|
if (info.created) {
|
|
return info.created;
|
|
} else {
|
|
const filenameNoExt = basename(mdFilePath, '.md');
|
|
const s = filenameNoExt.split('-');
|
|
return moment.utc(s[0], 'YYYYMMDD').toDate();
|
|
}
|
|
};
|