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

feat: individual gallery page #650

Open
wants to merge 11 commits into
base: feat-gallery
Choose a base branch
from
Open

feat: individual gallery page #650

wants to merge 11 commits into from

Conversation

alexgoff
Copy link
Contributor

Individual pages for images and videos in galleries.

Includes:

  • setup codegen for GQL, limited to gallery areas for now
  • proxy download for Canto images to convert content type from inline to attachment
  • support for image and video pages, all others should 404
  • static param generation for galleries and asset pages
  • revalidation for gallery entry types revalidates all child asset pages also

localhost_3000_gallery_camera-construction_i14v2mktbl35905mnh5d4f2721(Desktop)

@alexgoff alexgoff added the feature Something new! label Dec 27, 2024
@alexgoff alexgoff self-assigned this Dec 27, 2024
export async function generateStaticParams({
params: { locale, gallery },
}: GalleryProps) {
return getRecentAssets(locale, gallery);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

generates for all assets right now, can be modified if this adds too much to build time


export const dynamicParams = false;

export async function generateStaticParams({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

generates pages for all gallery entries

Copy link
Contributor Author

Choose a reason for hiding this comment

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

proxy downloader that uses the directUrlOriginal to fetch the file from Canto, cache to Next, and serve the file again with an attachment content type so that browsers download instead of navigating

@@ -49,6 +50,15 @@ const indexNow = async (uri: string) => {
console.info(`${status}: ${indexNowStatusText[status]}`);
};

const revalidateChildren = (parts: Array<string>): "layout" | "page" => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

since the assets in galleries are not represented in Craft, they need a new revalidation pipeline. Next has two types of revalidation: page which revalidates only the specified URL and layout which revalidates the URL + it's children.

In this exception, we want to use layout so that when the gallery entry is saved (either manually or by webhook), the assets are also revalidated to pick up any changes


loadEnvConfig(process.cwd());

const config: CodegenConfig = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

set up codegen so we can get typings for GQL responses

@@ -121,8 +121,7 @@ export const Title = styled.div`
transition: backgroud-color 0.2s;

@media (max-width: ${BREAK_PHABLET}) {
align-self: center;
justify-self: left;
place-self: center left;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

linter got mad at this, no clue why

const [, , scheme, contentId, directUrlOriginalHash] = pathname.split("/");

return (
<Buttonish
Copy link
Contributor Author

Choose a reason for hiding this comment

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

constructs a new download button that goes to our Next proxy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

since the Canto plugin does not have it's interfaces hooked up, I am using zod to create and validate schemas. This is useful even if the interfaces get hooked up since it acts as runtime validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Something new!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants