MCPcopy Index your code
hub / github.com/nodejs/nodejs.org / getFrontMatter

Function getFrontMatter

apps/site/scripts/blog-data/generate.mjs:21–48  ·  view source on GitHub ↗
(filename, source)

Source from the content-addressed store, hash-verified

19 * @param {string} source the source markdown content of the blog post
20 */
21const 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

Callers 1

generateBlogDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected