| 19 | * @param {string} source the source markdown content of the blog post |
| 20 | */ |
| 21 | const getFrontMatter = (filename, source) => { |
| 22 | const { |
| 23 | title = 'Untitled', |
| 24 | author = 'The Node.js Project', |
| 25 | username, |
| 26 | date = new Date(), |
| 27 | category = 'uncategorized', |
| 28 | } = graymatter(source).data; |
| 29 | |
| 30 | // We also use publishing years as categories for the blog |
| 31 | const publishYear = new Date(date).getUTCFullYear(); |
| 32 | |
| 33 | // Provides a full list of categories for the Blog Post which consists of |
| 34 | // all = (all blog posts), publish year and the actual blog category |
| 35 | const categories = [category, `year-${publishYear}`, 'all']; |
| 36 | |
| 37 | // this is the url used for the blog post it based on the category and filename |
| 38 | const slug = `/blog/${category}/${basename(filename, extname(filename))}`; |
| 39 | |
| 40 | return { |
| 41 | title, |
| 42 | author, |
| 43 | username, |
| 44 | date: new Date(date), |
| 45 | categories, |
| 46 | slug, |
| 47 | }; |
| 48 | }; |
| 49 | |
| 50 | /** |
| 51 | * This method is used to generate the Node.js Website Blog Data |