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

Create write redirects build task #4

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

camiloriosf
Copy link

No description provided.

Copy link
Contributor

@prceasar prceasar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the minor changes requested, please add documentation in the README for how this is used and configured, with a sample of the input JSON, and an example of the output structure. Also, how is that file consumed? Is that a netlify thing? If so, please explain that in the README as well.

Thanks!

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const localeSettings: any = await getSettings({
include: _.get(buildConfig, 'settingsInclude'),
contentTypeId: _.get(buildConfig, 'settingsContentType')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to make this more efficient, you should add a select argument: select: 'fields.redirects'.

};

const writeRedirects: BuildTask = async (buildConfig, { adapterConfig }): Promise<void> => {
const getSettings = buildConfig.useAdapter ? Contentful(adapterConfig).getGlobalSettings : getGlobalSettings;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are just parsing the response, I don't think we need to have both of these. If we don't need the adapter, we can just use the standard globalSettings request and parse it accordingly ({ fields : { redirects } }). Either way, whether you use the adapter or not, I would just stick to a single retrieval method. Because the line below (32) looks to me like it would fail if useAdapter != true...

await mkdirIfNotExists(CONTENT_DIR);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const localeSettings: any = await getSettings({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to have anything to do specifically with locales. Maybe call this variable globalSettings, or just settings?

@ct3685 ct3685 added the WIP Dont Merge Still a work in progress. label Oct 21, 2020
@ct3685 ct3685 marked this pull request as draft October 21, 2020 18:59
@ct3685 ct3685 removed the WIP Dont Merge Still a work in progress. label Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants