-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathnext.dynamic.constants.mjs
More file actions
93 lines (87 loc) · 2.92 KB
/
next.dynamic.constants.mjs
File metadata and controls
93 lines (87 loc) · 2.92 KB
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
'use strict';
import { provideBlogPosts } from '#site/next-data/providers/blogData';
import provideReleaseVersions from '#site/next-data/providers/releaseVersions';
import { blogData } from '#site/next.json.mjs';
import { BASE_PATH, BASE_URL } from './next.constants.mjs';
import { siteConfig } from './next.json.mjs';
/**
* This constant is used to create static routes on-the-fly that do not have a file-system
* counterpart route. This is useful for providing routes with matching Layout Names
* but that do not have Markdown content and a matching file for the route
*
* @type {Array<string>} A Map of pathname and Layout Name
*/
export const BLOG_DYNAMIC_ROUTES = [
// Provides Routes for all Blog Categories
...blogData.categories,
// Provides Routes for all Blog Categories w/ Pagination
...blogData.categories
// retrieves the amount of pages for each blog category
.map(c => [c, provideBlogPosts(c).pagination.pages])
// creates a numeric array for each page and define a pathname for
// each page for a category (i.e. blog/all/page/1)
.map(([c, t]) => [...Array(t).keys()].map(p => `${c}/page/${p + 1}`))
// flattens the array since we have a .map inside another .map
.flat(),
];
/**
* This constant is used to create static routes on-the-fly that do not have a file-system
* counterpart route. This is useful for providing routes with matching Layout Names
* but that do not have Markdown content and a matching file for the route
*
* @type {Array<string>} A Map of pathname and Layout Name
*/
export const ARCHIVE_DYNAMIC_ROUTES = [
// Creates dynamic routes for downloads archive pages for each version
// (e.g., /download/archive/v18.20.8, /download/archive/v20.19.2)
...(await provideReleaseVersions()),
];
/**
* This is the default Next.js Page Metadata for all pages
*
* @type {import('next').Metadata}
*/
export const PAGE_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 PAGE_VIEWPORT = {
themeColor: [
{
color: siteConfig.lightAccentColor,
media: '(prefers-color-scheme: light)',
},
{
color: siteConfig.darkAccentColor,
media: '(prefers-color-scheme: dark)',
},
],
width: 'device-width',
initialScale: 1,
maximumScale: 2,
};