Handle missing announcement file in dev-server

This commit is contained in:
infinite-persistence 2022-05-23 15:30:40 +08:00
parent 8c06dab10f
commit ceca6e3b84
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0

View file

@ -7,7 +7,10 @@ const loadAnnouncements = (homepageKeys) => {
homepageKeys.forEach((key) => { homepageKeys.forEach((key) => {
const file = path.join(__dirname, `../dist/announcement/${key.toLowerCase()}.md`); const file = path.join(__dirname, `../dist/announcement/${key.toLowerCase()}.md`);
const announcement = fs.readFileSync(file, 'utf8'); let announcement;
try {
announcement = fs.readFileSync(file, 'utf8');
} catch {}
announcements[key] = announcement ? announcement.trim() : ''; announcements[key] = announcement ? announcement.trim() : '';
}); });