forked from nodejs/nodejs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.dynamic.constants.mjs
107 lines (100 loc) · 3.63 KB
/
next.dynamic.constants.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
'use strict';
import { BASE_PATH, BASE_URL, CURRENT_YEAR } from './next.constants.mjs';
import { siteConfig } from './next.json.mjs';
import { defaultLocale } from './next.locales.mjs';
/**
* This is a list of all static routes or pages from the Website that we do not
* want to allow to be statically built on our Static Export Build.
*
* @type {((route: import('./types').RouteSegment) => boolean)[]} A list of Ignored Routes by Regular Expressions
*/
export const STATIC_ROUTES_IGNORES = [
// Ignore the 404 route on Static Generation
({ pathname }) => pathname === '404',
// This is used to ignore is used to ignore all blog routes except for the English language
({ locale, pathname }) =>
locale !== defaultLocale.code && /^blog\//.test(pathname),
// This is used to ignore the blog/pagination meta route
// @deprecated remove with website redesign
({ pathname }) => /^blog\/pagination/.test(pathname),
];
/**
* This is a list of all dynamic routes or pages from the Website that we do not
* want to allow to be dynamically access by our Dynamic Route Engine
*
* @type {RegExp[]} A list of Ignored Routes by Regular Expressions
* @deprecated remove with website redesign
*/
export const DYNAMIC_ROUTES_IGNORES = [
// This is used to ignore the blog/pagination route
/^blog\/pagination/,
];
/**
* This is a list of all static routes that we want to rewrite their pathnames
* into something else. This is useful when you want to have the current pathname in the route
* but replace the actual Markdown file that is being loaded by the Dynamic Route to something else
*
* @type {[RegexExp, (pathname: string) => string][]}
* @deprecated remove with website redesign
*/
export const DYNAMIC_ROUTES_REWRITES = [
[/^blog\/year-/, () => 'blog/pagination'],
];
/**
* This is a constant that should be used during runtime by (`getStaticPaths`) on `pages/[...path].tsx`
*
* This function is used to provide an extra set of routes that are not provided by `next.dynamic.mjs`
* static route discovery. This can happen when we have dynamic routes that **must** be provided
* within the static export (static build) of the website. This constant usually would be used along
* with a matching pathname on `DYNAMIC_ROUTES_REWRITES`.
*
* @type {string[]} A list of all the Dynamic Routes that are generated by the Website
* @deprecated remove with website redesign
*/
export const DYNAMIC_GENERATED_ROUTES = [
...Array.from(
// Statically generate a List of Years from Current Year
// til 2011 which is the oldest year with blog posts
{ length: CURRENT_YEAR - 2011 },
(_, i) => CURRENT_YEAR - i
).map(year => `blog/year-${year}`),
];
/**
* This is the default Next.js Page Metadata for all pages
*
* @type {import('next').Metadata}
*/
export const DEFAULT_METADATA = {
metadataBase: new URL(`${BASE_URL}${BASE_PATH}`),
title: siteConfig.title,
description: siteConfig.description,
robots: { index: true, follow: true },
twitter: {
card: siteConfig.twitter.card,
title: siteConfig.twitter.title,
creator: siteConfig.twitter.username,
images: {
url: siteConfig.twitter.img,
alt: siteConfig.twitter.imgAlt,
},
},
alternates: {
canonical: '',
languages: { 'x-default': '' },
types: {
'application/rss+xml': `${BASE_URL}${BASE_PATH}/en/feed/blog.xml`,
},
},
icons: { icon: siteConfig.favicon },
openGraph: { images: siteConfig.twitter.img },
};
/**
* This is the default Next.js Viewport Metadata for all pages
*
* @return {import('next').Viewport}
*/
export const DEFAULT_VIEWPORT = {
themeColor: siteConfig.accentColor,
width: 'device-width',
initialScale: 1,
};