The Node.js® Website
1'use strict';
2
3import {
4 provideBlogCategories,
5 provideBlogPosts,
6} from './next-data/providers/blogData';
7import { BASE_PATH, BASE_URL } from './next.constants.mjs';
8import { siteConfig } from './next.json.mjs';
9import { defaultLocale } from './next.locales.mjs';
10
11/**
12 * This is a list of all static routes or pages from the Website that we do not
13 * want to allow to be statically built on our Static Export Build.
14 *
15 * @type {Array<((route: import('./types').RouteSegment) => boolean)>} A list of Ignored Routes by Regular Expressions
16 */
17export const IGNORED_ROUTES = [
18 // This is used to ignore all blog routes except for the English language
19 ({ locale, pathname }) =>
20 locale !== defaultLocale.code && /^blog/.test(pathname),
21];
22
23/**
24 * This constant is used to create static routes on-the-fly that do not have a file-system
25 * counterpart route. This is useful for providing routes with matching Layout Names
26 * but that do not have Markdown content and a matching file for the route
27 *
28 * @type {Map<string, import('./types').Layouts>} A Map of pathname and Layout Name
29 */
30export const DYNAMIC_ROUTES = new Map([
31 // Provides Routes for all Blog Categories
32 ...provideBlogCategories().map(c => [`blog/${c}`, 'blog-category']),
33 // Provides Routes for all Blog Categories w/ Pagination
34 ...provideBlogCategories()
35 // retrieves the amount of pages for each blog category
36 .map(c => [c, provideBlogPosts(c).pagination.pages])
37 // creates a numeric array for each page and define a pathname for
38 // each page for a category (i.e. blog/all/page/1)
39 .map(([c, t]) => [...Array(t).keys()].map(p => `blog/${c}/page/${p + 1}`))
40 // creates a tuple of each pathname and layout for the route
41 .map(paths => paths.map(path => [path, 'blog-category']))
42 // flattens the array since we have a .map inside another .map
43 .flat(),
44]);
45
46/**
47 * This is the default Next.js Page Metadata for all pages
48 *
49 * @type {import('next').Metadata}
50 */
51export const PAGE_METADATA = {
52 metadataBase: new URL(`${BASE_URL}${BASE_PATH}`),
53 title: siteConfig.title,
54 description: siteConfig.description,
55 robots: { index: true, follow: true },
56 twitter: {
57 card: siteConfig.twitter.card,
58 title: siteConfig.twitter.title,
59 creator: siteConfig.twitter.username,
60 images: {
61 url: siteConfig.twitter.img,
62 alt: siteConfig.twitter.imgAlt,
63 },
64 },
65 alternates: {
66 canonical: '',
67 languages: { 'x-default': '' },
68 types: {
69 'application/rss+xml': `${BASE_URL}${BASE_PATH}/en/feed/blog.xml`,
70 },
71 },
72 icons: { icon: siteConfig.favicon },
73 openGraph: { images: siteConfig.twitter.img },
74};
75
76/**
77 * This is the default Next.js Viewport Metadata for all pages
78 *
79 * @return {import('next').Viewport}
80 */
81export const PAGE_VIEWPORT = {
82 themeColor: [
83 {
84 color: siteConfig.lightAccentColor,
85 media: '(prefers-color-scheme: light)',
86 },
87 {
88 color: siteConfig.darkAccentColor,
89 media: '(prefers-color-scheme: dark)',
90 },
91 ],
92 width: 'device-width',
93 initialScale: 1,
94 maximumScale: 1,
95};