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

Remove server side rendering #36

Merged
merged 7 commits into from
Jul 19, 2021
Merged

Remove server side rendering #36

merged 7 commits into from
Jul 19, 2021

Conversation

rjvelazco
Copy link
Collaborator

No description provided.

@vercel
Copy link

vercel bot commented Jul 15, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/dotcms/dotcms-documentation/4kjkzQ17fh7KvzG9sCTbvrVZJvXa
✅ Preview: https://dotcms-documentation-git-remove-server-side-rendering-dotcms.vercel.app

@rjvelazco rjvelazco requested a review from fmontes July 15, 2021 16:54
Comment on lines 59 to 64
<button
className={classNames(buttonClasses, arrowButtons)}
onClick={() => changePage(page - 1)}
>
<ArrowSVG className={leftArrowClasses} />
</button>
Copy link
Member

Choose a reason for hiding this comment

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

Component.

Copy link
Member

Choose a reason for hiding this comment

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

What's happened with this one?

Comment on lines 71 to 79
<button
className={classNames(
buttonClasses,
page == pagNumber && buttonClassesActive
)}
onClick={() => changePage(pagNumber)}
>
{pagNumber}
</button>
Copy link
Member

Choose a reason for hiding this comment

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

Reuse Component.

@@ -10,7 +10,7 @@ export const Search = (): JSX.Element => {
const handlerInput = ({ target }) => setSearch(target.value);
const handlerSubmit = (e) => {
e.preventDefault();
router.push(`/search/${search}/1`);
router.push(`/search/?search=${search}&pag=1`);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
router.push(`/search/?search=${search}&pag=1`);
router.push(`/search/?search=${search}&page=1`);

CodeshareCollection(
limit: 10,
limit: 100000,
Copy link
Member

Choose a reason for hiding this comment

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

Ask Daniel if we can pass a wildcard for "all" here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Apparently, there isn't.

Comment on lines 50 to 54
const { buttonCount, pagStart } = PaginationLenght({
totalPages,
page,
paginationLimit
});
Copy link
Member

Choose a reason for hiding this comment

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

This looks like the perfect candidate for you to learn how to create your own react hooks, I mean, you don't have to but I know you want it: https://reactjs.org/docs/hooks-custom.html 😂

next.config.js Outdated
Comment on lines 2 to 5
images: {
loader: 'imgix',
path: 'https://noop/'
},
Copy link
Member

Choose a reason for hiding this comment

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

Does this affect images in general?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've been reading and so far, it doesn't seem like it's going to affect the images. I took this solution from a problem they had here

Comment on lines 121 to 129
interface paramsUrlTitle {
link: string;
}

interface UrlTitleParams {
params: {
topic: string;
};
}
Copy link
Member

Choose a reason for hiding this comment

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

I think next have types for this.

If not, move this to the top.

Comment on lines 114 to 119
const buildParams = (data: paramsUrlTitle[], paths: UrlTitleParams[]): UrlTitleParams[] => {
data.forEach((item: paramsUrlTitle) => {
paths.push({ params: { topic: item.link } });
});
return paths;
};
Copy link
Member

Choose a reason for hiding this comment

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

Array.map

@@ -22,7 +22,8 @@ export const PaginationLenght = ({
const pagEnd = totalPages > paginationLimit ? paginationLimit : totalPages;
setButtonCount(new Array(pagEnd).fill(0));
setLoaded(true);
}, [page, totalPages, paginationLimit]);
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Member

Choose a reason for hiding this comment

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

We need to stop disabling things, why we have to here?

import classNames from 'classnames';

// Helper
import { PaginationLenght } from '@hook/pagination';
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import { PaginationLenght } from '@hook/pagination';
import { PaginationLenght } from '@hooks/pagination';

totalCount: number;
totalPages: number;
baseUrl?: string;
state?: Dispatch<SetStateAction<number>>;
Copy link
Member

Choose a reason for hiding this comment

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

This is not a state is more like a function to update something no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, you are right.

Comment on lines 24 to 29
const changePage = (page) => {
if (state) {
state(() => page);
} else {
router.push(baseUrl + page);
}
Copy link
Member

Choose a reason for hiding this comment

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

For what I can tell here, this function will update the page client side OR just navigating? so we are using the same Pagination for both cases?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, we are using the same component for both cases. Should we make two different paginations? If we do that, the code will be more readable.

Comment on lines 59 to 64
<button
className={classNames(buttonClasses, arrowButtons)}
onClick={() => changePage(page - 1)}
>
<ArrowSVG className={leftArrowClasses} />
</button>
Copy link
Member

Choose a reason for hiding this comment

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

What's happened with this one?

interface PaginationLenghtReturn {
pageStart: number;
buttonCount: number[];
loaded: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

we need this?

}
};

const totalPagesIsLowerThanLimit = (totalPages: number, limit: number): boolean => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const totalPagesIsLowerThanLimit = (totalPages: number, limit: number): boolean => {
const isTotalPagesLowerThanLimit = (totalPages: number, limit: number): boolean => {

return totalPages < limit;
};

const lowerThanHalfLimit = (page: number, halfLimit: number): boolean => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const lowerThanHalfLimit = (page: number, halfLimit: number): boolean => {
const isLowerThanHalfLimit = (page: number, halfLimit: number): boolean => {

next.config.js Outdated
Comment on lines 2 to 5
images: {
loader: 'imgix',
path: ''
},
Copy link
Member

Choose a reason for hiding this comment

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

What this does?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Image optimization with the next/Image component is not enabled for exported applications because optimization is done on demand, so we cannot use the default configuration.

If we are going to do an export and we want to use next/Image we must use an Optimization cloud provider different from default, nextJS gives a list here

});
return paths;
const buildParams = (data: paramsUrlTitle[]): UrlTitleParams[] => {
return data.map((item: paramsUrlTitle) => ({ params: { urlTitle: item.urlTitle } }));
Copy link
Member

Choose a reason for hiding this comment

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

FYI

Suggested change
return data.map((item: paramsUrlTitle) => ({ params: { urlTitle: item.urlTitle } }));
return data.map(({ urlTitle }: paramsUrlTitle) => ({ params: { urlTitle } }));

@fmontes fmontes marked this pull request as ready for review July 19, 2021 18:48
@fmontes fmontes merged commit 024abc0 into main Jul 19, 2021
@delete-merged-branch delete-merged-branch bot deleted the remove-server-side-rendering branch July 19, 2021 18:48
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.

None yet

2 participants