Skip to content

Commit

Permalink
Clean up logging when retrieving News and Event content
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjarling committed Jan 22, 2024
1 parent 52b3398 commit e5b4f92
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/markdown-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ var fs = require("fs");
module.exports = {
getMarkdownPageContent(filePath) {
try {
if (!fs.existsSync(filePath)) {
return null;
}
const readFile = fs.readFileSync(filePath, "utf-8");

if (!readFile) return null;

const { data: frontmatter, content } = matter(readFile);

return { content, frontmatter };
} catch (err) {
console.error("error processing markdown file");
console.error(`Error processing markdown file: ${filePath}. `);
}
},

Expand Down
6 changes: 4 additions & 2 deletions pages/news-and-events/[slug].jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ export async function getStaticProps({ params: { slug } }) {
content_type: "blogPost",
"fields.slug": slug,
});
blogPost = response.items[0].fields;
if (response.total > 0) {
blogPost = response.items[0].fields;
}
} catch {
console.error("Error retrieving blog post from Contentful");
console.error(`Error retrieving blog post: ${slug} from Contentful`);
}

const ogTitle = markdownContent
Expand Down

0 comments on commit e5b4f92

Please sign in to comment.