Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing and creating field based on Permission #192

Merged
merged 1 commit into from Jun 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
67 changes: 48 additions & 19 deletions src/gatsby-node.js
Expand Up @@ -402,28 +402,57 @@ exports.sourceNodes = async (
let urlParent = data['modified'][0]['parent']['@id'];
let urlList = [urlChild, urlParent];
urlList.forEach(async url => {
for await (const node of ploneNodeGenerator(
url,
token,
baseUrl,
expansions,
backlinks
)) {
logger.info(
`Creating node – ${node.id.replace(baseUrl, '') || '/'}`
try {
for await (const node of ploneNodeGenerator(
url,
token,
baseUrl,
expansions,
backlinks
)) {
logger.info(
`Creating node – ${node.id.replace(baseUrl, '') || '/'}`
);
createNode(node);
}
} catch (err) {
logger.error(
`Skipping node – ${url.replace(baseUrl, '')} (${err})`
);
createNode(node);
let node = getNode(url);
let breadcrumbsNode = getNode(`${url}/@breadcrumbs`);
let navigationNode = getNode(`${url}/@navigation`);
if (node) {
console.log(`node deleted at ${url}`);
deleteNode({ node: node });
}
if (breadcrumbsNode) {
deleteNode({ node: breadcrumbsNode });
}
if (navigationNode) {
deleteNode({ node: navigationNode });
}
}
});
const childItems = normalizeData(
await fetchPlone(`${urlChild}/@search`, token, {
...searchParams,
}),
baseUrl
);
for (const item of childItems.items) {
createNode(await fetchPloneNavigationNode(item._id, token, baseUrl));
createNode(await fetchPloneBreadcrumbsNode(item._id, token, baseUrl));
try {
const childItems = normalizeData(
await fetchPlone(`${urlChild}/@search`, token, {
...searchParams,
}),
baseUrl
);
for (const item of childItems.items) {
createNode(
await fetchPloneNavigationNode(item._id, token, baseUrl)
);
createNode(
await fetchPloneBreadcrumbsNode(item._id, token, baseUrl)
);
}
} catch (err) {
logger.error(
`Skipping node – ${urlChild.replace(baseUrl, '')} (${err})`
);
}
}
if (data['removed']) {
Expand Down