Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
guidePosts.map(async guidePost => {
const {metadata} = guidePost;
await createData(
// Note that this created data path must be in sync with metadataPath provided to mdx-loader
`${docuHash(metadata.source)}.json`,
JSON.stringify(metadata, null, 2),
);
addRoute({
path: metadata.permalink,
component: guidePostComponent,
exact: true,
modules: {
content: metadata.source,
},
});
}),
);
highlights.map(async highlight => {
const {metadata} = highlight;
await createData(
// Note that this created data path must be in sync with
// metadataPath provided to mdx-loader.
`${docuHash(metadata.source)}.json`,
JSON.stringify(metadata, null, 2),
);
addRoute({
path: metadata.permalink,
component: highlightComponent,
exact: true,
modules: {
content: metadata.source,
},
});
}),
);
await Promise.all(highlights.map(async (highlight) => {
const { metadata } = highlight;
await createData(
// Note that this created data path must be in sync with
// metadataPath provided to mdx-loader.
`${utils_1.docuHash(metadata.source)}.json`, JSON.stringify(metadata, null, 2));
addRoute({
path: metadata.permalink,
component: highlightComponent,
exact: true,
modules: {
content: metadata.source,
},
});
}));
},
metadataPath: (mdxPath: string) => {
const aliasedSource = aliasedSitePath(mdxPath, siteDir);
return path.join(
dataDir,
`${docuHash(aliasedSource)}.json`,
);
},
},
redirects.map(async redirect => {
const dest = JSON.stringify({to: redirect[1], forComponent: redirect[2]});
const destPath = await createData(`${docuHash(redirect[0])}.json`, dest);
addRoute({
path: redirect[0],
component: '@site/src/exports/redirect.js',
modules: {
dest: destPath,
},
exact: true,
});
}),
);
Object.keys(highlightTags).map(async tag => {
const {name, items, permalink} = highlightTags[tag];
tagsModule[tag] = {
allTagsPath: tagsPath,
slug: tag,
name,
count: items.length,
permalink,
};
const tagsMetadataPath = await createData(
`${docuHash(permalink)}.json`,
JSON.stringify(tagsModule[tag], null, 2),
);
addRoute({
path: permalink,
component: highlightTagComponent,
exact: true,
modules: {
items: items.map(highlightID => {
const metadata = highlightItemsToMetadata[highlightID];
return {
content: {
__import: true,
path: metadata.source,
query: {
truncated: true,
metadataPath: (mdxPath) => {
const aliasedSource = utils_1.aliasedSitePath(mdxPath, siteDir);
return path_1.default.join(dataDir, `${utils_1.docuHash(aliasedSource)}.json`);
},
},
metadataPath: (mdxPath) => {
const aliasedPath = aliasedSitePath(mdxPath, siteDir);
return path.join(
dataDir,
`${docuHash(aliasedPath)}.json`,
);
},
},
await Promise.all(Object.keys(highlightTags).map(async (tag) => {
const { name, items, permalink } = highlightTags[tag];
tagsModule[tag] = {
allTagsPath: tagsPath,
slug: tag,
name,
count: items.length,
permalink,
};
const tagsMetadataPath = await createData(`${utils_1.docuHash(permalink)}.json`, JSON.stringify(tagsModule[tag], null, 2));
addRoute({
path: permalink,
component: highlightTagComponent,
exact: true,
modules: {
items: items.map(highlightID => {
const metadata = highlightItemsToMetadata[highlightID];
return {
content: {
__import: true,
path: metadata.source,
query: {
truncated: true,
},
},
};