@jpmorganchase/mosaic-plugins 0.1.0-beta.6 → 0.1.0-beta.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/$AliasPlugin.d.ts +10 -0
- package/dist/$AliasPlugin.js +39 -48
- package/dist/$AliasPlugin.js.map +1 -1
- package/dist/$CodeModPlugin.d.ts +7 -0
- package/dist/$CodeModPlugin.js +18 -30
- package/dist/$CodeModPlugin.js.map +1 -1
- package/dist/$RefPlugin.d.ts +31 -0
- package/dist/$RefPlugin.js +131 -127
- package/dist/$RefPlugin.js.map +1 -1
- package/dist/$TagPlugin.d.ts +28 -0
- package/dist/$TagPlugin.js +37 -56
- package/dist/$TagPlugin.js.map +1 -1
- package/dist/BreadcrumbsPlugin.d.ts +19 -0
- package/dist/BreadcrumbsPlugin.js +84 -32
- package/dist/BreadcrumbsPlugin.js.map +1 -1
- package/dist/BrokenLinksPlugin.d.ts +10 -0
- package/dist/BrokenLinksPlugin.js +80 -0
- package/dist/BrokenLinksPlugin.js.map +1 -0
- package/dist/FragmentPlugin.d.ts +7 -0
- package/dist/FragmentPlugin.js +92 -0
- package/dist/FragmentPlugin.js.map +1 -0
- package/dist/LazyPagePlugin.d.ts +14 -0
- package/dist/LazyPagePlugin.js +57 -87
- package/dist/LazyPagePlugin.js.map +1 -1
- package/dist/PagesWithoutFileExtPlugin.d.ts +9 -0
- package/dist/PagesWithoutFileExtPlugin.js +19 -31
- package/dist/PagesWithoutFileExtPlugin.js.map +1 -1
- package/dist/PropsTablePlugin.d.ts +6 -0
- package/dist/PropsTablePlugin.js +88 -0
- package/dist/PropsTablePlugin.js.map +1 -0
- package/dist/PublicAssetsPlugin.d.ts +18 -0
- package/dist/PublicAssetsPlugin.js +28 -0
- package/dist/PublicAssetsPlugin.js.map +1 -0
- package/dist/ReadingTimePlugin.d.ts +10 -0
- package/dist/ReadingTimePlugin.js +36 -0
- package/dist/ReadingTimePlugin.js.map +1 -0
- package/dist/SearchIndexPlugin.d.ts +56 -0
- package/dist/SearchIndexPlugin.js +154 -0
- package/dist/SearchIndexPlugin.js.map +1 -0
- package/dist/SharedConfigPlugin.d.ts +14 -0
- package/dist/SharedConfigPlugin.js +134 -38
- package/dist/SharedConfigPlugin.js.map +1 -1
- package/dist/SidebarPlugin.d.ts +44 -0
- package/dist/SidebarPlugin.js +246 -95
- package/dist/SidebarPlugin.js.map +1 -1
- package/dist/SiteMapPlugin.d.ts +9 -0
- package/dist/SiteMapPlugin.js +20 -36
- package/dist/SiteMapPlugin.js.map +1 -1
- package/dist/TableOfContentsPlugin.d.ts +20 -0
- package/dist/TableOfContentsPlugin.js +43 -0
- package/dist/TableOfContentsPlugin.js.map +1 -0
- package/dist/utils/PluginError.d.ts +7 -0
- package/dist/utils/PluginError.js +13 -0
- package/dist/utils/PluginError.js.map +1 -0
- package/dist/utils/mergePageConent.d.ts +16 -0
- package/dist/utils/mergePageConent.js +23 -0
- package/dist/utils/mergePageConent.js.map +1 -0
- package/dist/utils/normaliseRefs.d.ts +1 -0
- package/dist/utils/normaliseRefs.js +52 -69
- package/dist/utils/normaliseRefs.js.map +1 -1
- package/dist/utils/sortSidebarData.d.ts +19 -0
- package/dist/utils/sortSidebarData.js +35 -0
- package/dist/utils/sortSidebarData.js.map +1 -0
- package/package.json +48 -15
- package/CHANGELOG.md +0 -58
- package/dist/NextPrevPagePlugin.js +0 -63
- package/dist/NextPrevPagePlugin.js.map +0 -1
- package/dist/ReadingTimePlugin.mjs +0 -119
- package/dist/ReadingTimePlugin.mjs.map +0 -1
- package/dist/TableOfContentsPlugin.mjs +0 -140
- package/dist/TableOfContentsPlugin.mjs.map +0 -1
package/dist/SidebarPlugin.js
CHANGED
|
@@ -1,109 +1,260 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { sidebarSortConfigSchema } from '@jpmorganchase/mosaic-schemas';
|
|
3
|
+
import { cloneDeep } from 'lodash-es';
|
|
4
|
+
import { sortSidebarData } from './utils/sortSidebarData.js';
|
|
5
|
+
function createFileGlob(patterns, pageExtensions) {
|
|
6
|
+
if (Array.isArray(patterns)) {
|
|
7
|
+
return patterns.map(pattern => createFileGlob(pattern, pageExtensions));
|
|
8
|
+
}
|
|
9
|
+
if (pageExtensions.length === 1) {
|
|
10
|
+
return `${patterns}${pageExtensions[0]}`;
|
|
11
|
+
}
|
|
12
|
+
return `${patterns}{${pageExtensions.join(',')}}`;
|
|
13
|
+
}
|
|
14
|
+
function getPageLevel(page) {
|
|
15
|
+
return page.route.split('/').length - 2;
|
|
16
|
+
}
|
|
17
|
+
function sortByPathLevel(pathA, pathB) {
|
|
18
|
+
const pathALevel = pathA.split('/').length;
|
|
19
|
+
const pathBLevel = pathB.split('/').length;
|
|
20
|
+
return pathBLevel - pathALevel;
|
|
21
|
+
}
|
|
16
22
|
/**
|
|
17
|
-
*
|
|
23
|
+
* Given the sharedSortConfig
|
|
24
|
+
* 1. find the field specified by 'field' in the sort config
|
|
25
|
+
* 2. transform the field value into the type specified by 'dataType'
|
|
26
|
+
* @param page
|
|
27
|
+
* @param sharedSortConfig
|
|
28
|
+
* @returns transformed field value
|
|
29
|
+
*/
|
|
30
|
+
function getSortFieldData(page, sharedSortConfig) {
|
|
31
|
+
let fieldData;
|
|
32
|
+
if (sharedSortConfig !== undefined) {
|
|
33
|
+
const { field, dataType = 'string' } = sharedSortConfig;
|
|
34
|
+
field
|
|
35
|
+
.replace(/^(?:\.\.\/|\.\/)+/, '')
|
|
36
|
+
.split('/')
|
|
37
|
+
.forEach(part => {
|
|
38
|
+
const source = fieldData === undefined ? page : fieldData;
|
|
39
|
+
if (Object.prototype.hasOwnProperty.call(source, part)) {
|
|
40
|
+
fieldData = source[part];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
switch (dataType) {
|
|
44
|
+
case 'date':
|
|
45
|
+
fieldData = new Date(fieldData).getTime(); // call getTime to convert to a number
|
|
46
|
+
break;
|
|
47
|
+
case 'string':
|
|
48
|
+
fieldData = String(fieldData);
|
|
49
|
+
break;
|
|
50
|
+
case 'number':
|
|
51
|
+
fieldData = Number(fieldData);
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
fieldData = String(fieldData);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return fieldData;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Sorts the pages in a folder by priority and then exports a JSON file with the
|
|
18
61
|
* sidebar tree from that directory downwards and adds sidebar data into frontmatter for each page.
|
|
62
|
+
*
|
|
63
|
+
* Additionally, add to frontmatter
|
|
64
|
+
* navigation -> prev -> { title, route }
|
|
65
|
+
* navigation -> next -> { title, route }
|
|
66
|
+
* to define the previous/next page in the page sequence, as defined by sidebar label and priority
|
|
19
67
|
*/
|
|
20
68
|
const SidebarPlugin = {
|
|
21
|
-
$beforeSend(mutableFilesystem, { config, serialiser, ignorePages, pageExtensions },
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
69
|
+
async $beforeSend(mutableFilesystem, { config, serialiser, ignorePages, pageExtensions }, { filename = 'sidebar.json', rootDirGlob = '*' }) {
|
|
70
|
+
/**
|
|
71
|
+
* Create a list of pages that should be used to build a sidebar.json
|
|
72
|
+
* @param dirName - root path of sidebar
|
|
73
|
+
*/
|
|
74
|
+
async function createPageList(rootDir) {
|
|
75
|
+
const isChildOfRootDir = pagePath => {
|
|
76
|
+
const pageDir = path.dirname(pagePath);
|
|
77
|
+
return pageDir.indexOf(rootDir) === 0;
|
|
78
|
+
};
|
|
79
|
+
const pagePaths = (await mutableFilesystem.promises.glob(createFileGlob(['**'], pageExtensions), {
|
|
80
|
+
cwd: String(rootDir),
|
|
81
|
+
ignore: ignorePages.map(ignore => `**/${ignore}`)
|
|
82
|
+
}));
|
|
83
|
+
const filteredPagePaths = pagePaths.filter(isChildOfRootDir);
|
|
84
|
+
const pageList = await Promise.all(filteredPagePaths.map(async (pagePath) => {
|
|
85
|
+
return mutableFilesystem.promises.readFile(pagePath).then(serializedContent => {
|
|
86
|
+
return serialiser.deserialise(pagePath, serializedContent);
|
|
87
|
+
});
|
|
88
|
+
}));
|
|
89
|
+
return pageList;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Group the pages into parent/child hierarchy
|
|
93
|
+
* @param pages - sidebar pages
|
|
94
|
+
*/
|
|
95
|
+
function createGroupMap(pages) {
|
|
96
|
+
const sortConfigPages = {};
|
|
97
|
+
return pages.reduce((result, page) => {
|
|
98
|
+
const name = page.sidebar?.label || page.title;
|
|
99
|
+
const sharedSortConfig = page?.sharedConfig?.sidebar?.sort;
|
|
100
|
+
if (sharedSortConfig) {
|
|
101
|
+
try {
|
|
102
|
+
sidebarSortConfigSchema.parse(sharedSortConfig);
|
|
103
|
+
sortConfigPages[`${path.posix.dirname(page.fullPath)}`] = sharedSortConfig;
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
/**
|
|
107
|
+
* Don't throw a PluginError here as this will stop the sidebar being generated.
|
|
108
|
+
* Plugins need a way to log errors/warnings without exceptions
|
|
109
|
+
*/
|
|
110
|
+
console.error(`[Mosaic] SidebarPlugin - Invalid sidebar sort config found in ${page.fullPath}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const priority = page.sidebar?.priority;
|
|
114
|
+
const id = page.route;
|
|
115
|
+
const isGroup = /\/index$/.test(page.route);
|
|
116
|
+
const groupPath = path.posix.dirname(page.fullPath);
|
|
117
|
+
const level = getPageLevel(page);
|
|
118
|
+
const newChildNode = {
|
|
119
|
+
id,
|
|
120
|
+
fullPath: page.fullPath,
|
|
121
|
+
name,
|
|
122
|
+
priority,
|
|
123
|
+
data: { level, link: page.route },
|
|
124
|
+
childNodes: []
|
|
125
|
+
};
|
|
126
|
+
if (!isGroup && sortConfigPages[`${path.posix.dirname(page.fullPath)}`] !== undefined) {
|
|
127
|
+
const fieldData = getSortFieldData(page, sortConfigPages[`${path.posix.dirname(page.fullPath)}`]);
|
|
128
|
+
newChildNode.sharedSortConfig = {
|
|
129
|
+
...sortConfigPages[`${path.posix.dirname(page.fullPath)}`],
|
|
130
|
+
fieldData
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if (isGroup) {
|
|
134
|
+
result[groupPath] = {
|
|
135
|
+
...newChildNode,
|
|
136
|
+
...result[groupPath]
|
|
137
|
+
};
|
|
42
138
|
}
|
|
43
|
-
|
|
139
|
+
else {
|
|
140
|
+
const childNodes = Object.prototype.hasOwnProperty.call(result, groupPath)
|
|
141
|
+
? result[groupPath].childNodes
|
|
142
|
+
: [];
|
|
143
|
+
result[groupPath] = {
|
|
144
|
+
...result[groupPath],
|
|
145
|
+
childNodes: [...childNodes, newChildNode]
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
return result;
|
|
149
|
+
}, {});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Link the group map to their parents
|
|
153
|
+
* @param groupMap - unlinked groups of pages
|
|
154
|
+
* @param dirName - root path of sidebar
|
|
155
|
+
*/
|
|
156
|
+
function linkGroupMap(groupMap, dirName) {
|
|
157
|
+
const linkedGroupMap = cloneDeep(groupMap);
|
|
158
|
+
const sortedGroupMapKeys = Object.keys(linkedGroupMap).sort(sortByPathLevel);
|
|
159
|
+
sortedGroupMapKeys.forEach(groupPath => {
|
|
160
|
+
let parentGroupPath = path.posix.dirname(groupPath);
|
|
161
|
+
if (linkedGroupMap[parentGroupPath] === undefined) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
linkedGroupMap[parentGroupPath].childNodes = [
|
|
165
|
+
...linkedGroupMap[parentGroupPath].childNodes,
|
|
166
|
+
linkedGroupMap[groupPath]
|
|
167
|
+
];
|
|
168
|
+
});
|
|
169
|
+
return [linkedGroupMap[dirName]];
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Link each page to a sidebar.json file via ref
|
|
173
|
+
* @param pages - sidebar pages
|
|
174
|
+
* @param dirName - root path of sidebar
|
|
175
|
+
*/
|
|
176
|
+
function addSidebarDataToFrontmatter(pages, dirName) {
|
|
177
|
+
pages.forEach(page => {
|
|
178
|
+
config.setRef(String(page.fullPath), ['sidebarData', '$ref'], path.posix.join(dirName, filename, '#', 'pages'));
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
const createNavigationRefs = (currPage, prevPage, nextPage) => {
|
|
182
|
+
if (prevPage) {
|
|
183
|
+
config.setRef(currPage, ['navigation', 'prev', 'title', '$ref'], `${prevPage}#/title`);
|
|
184
|
+
config.setRef(currPage, ['navigation', 'prev', 'route', '$ref'], `${prevPage}#/route`);
|
|
44
185
|
}
|
|
45
|
-
|
|
46
|
-
config.setRef(
|
|
47
|
-
|
|
48
|
-
? config.setRef(sidebarFilePath, ['pages', `${i}`, 'name', '$ref'], `${page.fullPath}#/sidebar/label`)
|
|
49
|
-
: config.setRef(sidebarFilePath, ['pages', `${i}`, 'name', '$ref'], `${page.fullPath}#/title`);
|
|
50
|
-
config.setRef(sidebarFilePath, ['pages', `${i}`, 'data', 'link', '$ref'], `${page.fullPath}#/route`);
|
|
186
|
+
if (nextPage) {
|
|
187
|
+
config.setRef(currPage, ['navigation', 'next', 'title', '$ref'], `${nextPage}#/title`);
|
|
188
|
+
config.setRef(currPage, ['navigation', 'next', 'route', '$ref'], `${nextPage}#/route`);
|
|
51
189
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
190
|
+
};
|
|
191
|
+
function addNavigationToFrontmatter(pages) {
|
|
192
|
+
let prevParentPage, nextParentPage;
|
|
193
|
+
const getLastPage = pages => {
|
|
194
|
+
if (pages[pages.length - 1].childNodes?.length) {
|
|
195
|
+
return getLastPage(pages[pages.length - 1].childNodes);
|
|
196
|
+
}
|
|
197
|
+
return pages[pages.length - 1];
|
|
198
|
+
};
|
|
199
|
+
const lastPage = getLastPage(pages);
|
|
200
|
+
const isFirstPage = page => page === pages[0];
|
|
201
|
+
const isLastPage = page => page === lastPage;
|
|
202
|
+
function recursiveAddNavigation(pages) {
|
|
203
|
+
pages.forEach((page, pageIndex) => {
|
|
204
|
+
const { fullPath: currPage } = page;
|
|
205
|
+
let prevPage, nextPage;
|
|
206
|
+
prevPage = prevParentPage;
|
|
207
|
+
prevParentPage = isFirstPage(page) ? undefined : pages[pageIndex].fullPath;
|
|
208
|
+
if (page.childNodes?.length) {
|
|
209
|
+
nextPage = page.childNodes[0].fullPath;
|
|
210
|
+
nextParentPage =
|
|
211
|
+
pageIndex < pages.length - 1 ? pages[pageIndex + 1].fullPath : nextParentPage;
|
|
212
|
+
}
|
|
213
|
+
else if (pageIndex < pages.length - 1) {
|
|
214
|
+
nextPage = pages[pageIndex + 1].fullPath;
|
|
69
215
|
}
|
|
216
|
+
else {
|
|
217
|
+
nextPage = isLastPage(page) ? undefined : nextParentPage;
|
|
218
|
+
}
|
|
219
|
+
if (currPage !== undefined) {
|
|
220
|
+
createNavigationRefs(currPage, prevPage, nextPage);
|
|
221
|
+
}
|
|
222
|
+
recursiveAddNavigation(page.childNodes);
|
|
70
223
|
});
|
|
71
224
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
225
|
+
recursiveAddNavigation(pages);
|
|
226
|
+
}
|
|
227
|
+
const rootUserJourneys = await mutableFilesystem.promises.glob(rootDirGlob, {
|
|
228
|
+
onlyDirectories: true,
|
|
229
|
+
extglob: true,
|
|
230
|
+
cwd: '/'
|
|
79
231
|
});
|
|
232
|
+
const removeExcludedPages = page => !(page.sidebar && page.sidebar.exclude);
|
|
233
|
+
function moveRootPageDown(pagesByPriority) {
|
|
234
|
+
const rootPage = pagesByPriority[0];
|
|
235
|
+
const pagesWithRootMovedDown = rootPage.childNodes;
|
|
236
|
+
pagesWithRootMovedDown.unshift(rootPage);
|
|
237
|
+
rootPage.childNodes = [];
|
|
238
|
+
return pagesWithRootMovedDown;
|
|
239
|
+
}
|
|
240
|
+
await Promise.all(rootUserJourneys.map(async (rootDir) => {
|
|
241
|
+
const sidebarFilePath = path.posix.join(String(rootDir), filename);
|
|
242
|
+
const pages = await createPageList(rootDir);
|
|
243
|
+
const includedPages = pages.filter(page => removeExcludedPages(page));
|
|
244
|
+
const groupMap = createGroupMap(includedPages);
|
|
245
|
+
const sidebarData = linkGroupMap(groupMap, rootDir);
|
|
246
|
+
if (sidebarData[0] === undefined) {
|
|
247
|
+
console.warn(`[Mosaic] SidebarPlugin - Unable to create a Sidebar grouping for ${rootDir}`);
|
|
248
|
+
console.log('[Mosaic] SidebarPlugin - likely you have a directory without an index file');
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const sortedSidebarData = sortSidebarData(sidebarData);
|
|
252
|
+
addNavigationToFrontmatter(sortedSidebarData);
|
|
253
|
+
const pagesWithRootMovedDown = moveRootPageDown(sortedSidebarData);
|
|
254
|
+
await mutableFilesystem.promises.writeFile(sidebarFilePath, JSON.stringify({ pages: pagesWithRootMovedDown }));
|
|
255
|
+
addSidebarDataToFrontmatter(pages, rootDir);
|
|
256
|
+
}));
|
|
80
257
|
}
|
|
81
258
|
};
|
|
82
|
-
|
|
83
|
-
function createFileGlob(patterns, pageExtensions) {
|
|
84
|
-
if (Array.isArray(patterns)) {
|
|
85
|
-
return patterns.map(pattern => createFileGlob(pattern, pageExtensions));
|
|
86
|
-
}
|
|
87
|
-
if (pageExtensions.length === 1) {
|
|
88
|
-
return `${patterns}${pageExtensions[0]}`;
|
|
89
|
-
}
|
|
90
|
-
return `${patterns}{${pageExtensions.join(',')}}`;
|
|
91
|
-
}
|
|
92
|
-
function isSubfolderIndex(page, dirName) {
|
|
93
|
-
return page.fullPath.split('/').length == String(dirName).split('/').length + 2;
|
|
94
|
-
}
|
|
95
|
-
function sortFn(pageA, pageB, dirName) {
|
|
96
|
-
// Always pin /index to the front
|
|
97
|
-
if (pageA.route === dirName + '/index') {
|
|
98
|
-
return -1;
|
|
99
|
-
}
|
|
100
|
-
if (pageB.route === dirName + '/index') {
|
|
101
|
-
return 1;
|
|
102
|
-
}
|
|
103
|
-
return ((pageB.sidebar && pageB.sidebar.priority ? pageB.sidebar.priority : -1) -
|
|
104
|
-
(pageA.sidebar && pageA.sidebar.priority ? pageA.sidebar.priority : -1));
|
|
105
|
-
}
|
|
106
|
-
function filterFn(page) {
|
|
107
|
-
return !(page.sidebar && page.sidebar.exclude);
|
|
108
|
-
}
|
|
259
|
+
export default SidebarPlugin;
|
|
109
260
|
//# sourceMappingURL=SidebarPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SidebarPlugin.js","sourceRoot":"","sources":["../src/SidebarPlugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SidebarPlugin.js","sourceRoot":"","sources":["../src/SidebarPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,uBAAuB,EAAmB,MAAM,+BAA+B,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAwB,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C,KAAK,SAAS,EAAE;gBAChC,OAAO,CAAC,IAAI,CACV,oEAAoE,OAAO,EAAE,CAC9E,CAAC;gBACF,OAAO,CAAC,GAAG,CACT,4EAA4E,CAC7E,CAAC;gBACF,OAAO;aACR;YACD,MAAM,iBAAiB,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;YACvD,0BAA0B,CAAC,iBAAiB,CAAC,CAAC;YAC9C,MAAM,sBAAsB,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;YACnE,MAAM,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CACxC,eAAe,EACf,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC,CAClD,CAAC;YACF,2BAA2B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC9C,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAC;AACJ,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Page, Plugin as PluginType } from '@jpmorganchase/mosaic-types';
|
|
2
|
+
interface SiteMapPluginConfigData {
|
|
3
|
+
sitemaps: Array<string[]>;
|
|
4
|
+
}
|
|
5
|
+
interface SiteMapPluginOptions {
|
|
6
|
+
siteUrl: string;
|
|
7
|
+
}
|
|
8
|
+
declare const SiteMapPlugin: PluginType<Page, SiteMapPluginOptions, SiteMapPluginConfigData, SiteMapPluginConfigData>;
|
|
9
|
+
export default SiteMapPlugin;
|
package/dist/SiteMapPlugin.js
CHANGED
|
@@ -1,44 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
import path from 'path';
|
|
12
2
|
const SiteMapPlugin = {
|
|
13
3
|
// Merge together all of the individual sitemaps from each source
|
|
14
|
-
afterUpdate(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.join('\n'))
|
|
24
|
-
.join('') +
|
|
25
|
-
'\n</urlset>');
|
|
26
|
-
});
|
|
4
|
+
async afterUpdate(_, { sharedFilesystem, globalConfig }, { siteUrl }) {
|
|
5
|
+
if (!Array.isArray(globalConfig.data.sitemaps)) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const urls = globalConfig.data.sitemaps.map(items => items
|
|
9
|
+
.map(item => `\t<url>\n\t\t<loc>${new URL(path.posix.join(path.posix.dirname(item), path.posix.basename(item, path.posix.extname(item))), siteUrl)}</loc>\n\t\t<changefreq>weekly</changefreq>\n\t\t<priority>0.5</priority>\n\t</url>`)
|
|
10
|
+
.join('\n'));
|
|
11
|
+
const urlSet = `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n ${urls}\n\n</urlset>`;
|
|
12
|
+
await sharedFilesystem.promises.writeFile('/sitemap.xml', urlSet);
|
|
27
13
|
},
|
|
28
14
|
// Store a sitemap for just this source
|
|
29
|
-
$beforeSend(mutableFilesystem, { config, ignorePages }
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
]
|
|
39
|
-
});
|
|
15
|
+
async $beforeSend(mutableFilesystem, { config, ignorePages }) {
|
|
16
|
+
config.setData({
|
|
17
|
+
sitemaps: [
|
|
18
|
+
(await mutableFilesystem.promises.glob('**', {
|
|
19
|
+
onlyFiles: true,
|
|
20
|
+
ignore: ignorePages.map(ignore => `**/${ignore}`),
|
|
21
|
+
cwd: '/'
|
|
22
|
+
}))
|
|
23
|
+
]
|
|
40
24
|
});
|
|
41
25
|
}
|
|
42
26
|
};
|
|
43
|
-
|
|
27
|
+
export default SiteMapPlugin;
|
|
44
28
|
//# sourceMappingURL=SiteMapPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SiteMapPlugin.js","sourceRoot":"","sources":["../src/SiteMapPlugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SiteMapPlugin.js","sourceRoot":"","sources":["../src/SiteMapPlugin.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AAUxB,MAAM,aAAa,GAKf;IACF,iEAAiE;IACjE,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,EAAE,gBAAgB,EAAE,YAAY,EAAE,EAAE,EAAE,OAAO,EAAE;QAClE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YAC9C,OAAO;SACR;QAED,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAClD,KAAK;aACF,GAAG,CACF,IAAI,CAAC,EAAE,CACL,qBAAqB,IAAI,GAAG,CAC1B,IAAI,CAAC,KAAK,CAAC,IAAI,CACb,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EACxB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CACpD,EACD,OAAO,CACR,qFAAqF,CACzF;aACA,IAAI,CAAC,IAAI,CAAC,CACd,CAAC;QAEF,MAAM,MAAM,GAAG,kEAAkE,IAAI,eAAe,CAAC;QACrG,MAAM,gBAAgB,CAAC,QAAQ,CAAC,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IACpE,CAAC;IACD,uCAAuC;IACvC,KAAK,CAAC,WAAW,CAAC,iBAAiB,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE;QAC1D,MAAM,CAAC,OAAO,CAAC;YACb,QAAQ,EAAE;gBACR,CAAC,MAAM,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE;oBAC3C,SAAS,EAAE,IAAI;oBACf,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,MAAM,EAAE,CAAC;oBACjD,GAAG,EAAE,GAAG;iBACT,CAAC,CAAkB;aACrB;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Page, Plugin as PluginType } from '@jpmorganchase/mosaic-types';
|
|
2
|
+
import type { Heading as MarkdownHeading } from 'mdast';
|
|
3
|
+
declare type TOCItem = {
|
|
4
|
+
level: number;
|
|
5
|
+
id: string;
|
|
6
|
+
text: string;
|
|
7
|
+
};
|
|
8
|
+
interface TableOfContentsPluginPage extends Page {
|
|
9
|
+
tableOfContents?: TOCItem[];
|
|
10
|
+
}
|
|
11
|
+
declare type Rank = MarkdownHeading['depth'];
|
|
12
|
+
interface TableOfContentsPluginOptions {
|
|
13
|
+
minRank: Rank;
|
|
14
|
+
maxRank: Rank;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Calculates table of contents from page headings
|
|
18
|
+
*/
|
|
19
|
+
declare const TableOfContentsPlugin: PluginType<TableOfContentsPluginPage, TableOfContentsPluginOptions>;
|
|
20
|
+
export default TableOfContentsPlugin;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import Slugger from 'github-slugger';
|
|
2
|
+
import remarkParse from 'remark-parse';
|
|
3
|
+
import { unified } from 'unified';
|
|
4
|
+
import remarkStringify from 'remark-stringify';
|
|
5
|
+
import remarkHeadings from '@vcarl/remark-headings';
|
|
6
|
+
const getValue = (path, obj) => path.split('.').reduce((acc, c) => acc && acc[c], obj);
|
|
7
|
+
const parsePageHeading = (page, heading) => {
|
|
8
|
+
let parsedHeading = heading.trim();
|
|
9
|
+
if (parsedHeading.indexOf('{meta') === 0) {
|
|
10
|
+
const metaPath = parsedHeading.replace(/^{meta\./, '').replace(/\}$/, '');
|
|
11
|
+
parsedHeading = getValue(metaPath, page).trim();
|
|
12
|
+
}
|
|
13
|
+
return parsedHeading;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Calculates table of contents from page headings
|
|
17
|
+
*/
|
|
18
|
+
const TableOfContentsPlugin = {
|
|
19
|
+
async $afterSource(pages, _, { minRank, maxRank }) {
|
|
20
|
+
const processor = unified().use(remarkParse).use(remarkStringify).use(remarkHeadings);
|
|
21
|
+
for (const page of pages) {
|
|
22
|
+
const slugger = new Slugger();
|
|
23
|
+
if (page.content) {
|
|
24
|
+
const vfile = await processor.process(page.content);
|
|
25
|
+
const headings = vfile.data.headings;
|
|
26
|
+
const items = headings
|
|
27
|
+
.filter(heading => heading.depth >= minRank && heading.depth <= maxRank)
|
|
28
|
+
.map(validHeading => {
|
|
29
|
+
const text = parsePageHeading(page, validHeading.value);
|
|
30
|
+
return {
|
|
31
|
+
level: validHeading.depth,
|
|
32
|
+
id: slugger.slug(text),
|
|
33
|
+
text
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
page.tableOfContents = items;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return pages;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
export default TableOfContentsPlugin;
|
|
43
|
+
//# sourceMappingURL=TableOfContentsPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableOfContentsPl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,GAAG,IAAI,OAAO,EAAE,CAAC;YAC9B,IAAI,IAAI,CAAC,OAAO,EAAE;gBAChB,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACpD,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,QAA8C,CAAC;gBAC3E,MAAM,KAAK,GAAc,QAAQ;qBAC9B,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC;qBACvE,GAAG,CAAC,YAAY,CAAC,EAAE;oBAClB,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;oBACxD,OAAO;wBACL,KAAK,EAAE,YAAY,CAAC,KAAK;wBACzB,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;wBACtB,IAAI;qBACL,CAAC;gBACJ,CAAC,CAAC,CAAC;gBACL,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;aAC9B;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default class PluginError extends Error {
|
|
2
|
+
fullPath;
|
|
3
|
+
lifecycleMethod;
|
|
4
|
+
pluginModulePath;
|
|
5
|
+
pluginName;
|
|
6
|
+
constructor(message, fullPath) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = 'PluginError';
|
|
9
|
+
this.fullPath = fullPath;
|
|
10
|
+
Object.setPrototypeOf(this, PluginError.prototype);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=PluginError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginError.js","sourceRoot":"","sources":["../../src/utils/PluginError.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,KAAK;IAC5C,QAAQ,CAAS;IACjB,eAAe,CAAS;IACxB,gBAAgB,CAAS;IACzB,UAAU,CAAS;IACnB,YAAY,OAAe,EAAE,QAAiB;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Options } from 'deepmerge';
|
|
2
|
+
/**
|
|
3
|
+
* deeply merges the `updatedPageMetadata` into the `originalPageMetadata`.
|
|
4
|
+
*
|
|
5
|
+
* By default, array values in `updatedPageMetadata` *overwrite* `originalPageMetadata` array values completely rather than concatenating them.
|
|
6
|
+
*
|
|
7
|
+
* To override this behavior use the `options` parameter as mentioned here:
|
|
8
|
+
* https://www.npmjs.com/package/deepmerge
|
|
9
|
+
*
|
|
10
|
+
* @param originalPageMetadata
|
|
11
|
+
* @param updatedPageMetadata
|
|
12
|
+
* @param options
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
declare function mergePageContent<T, U>(originalPageMetadata: Partial<T>, updatedPageMetadata: U, options?: Options): T & U;
|
|
16
|
+
export { mergePageContent };
|