Skip to content

Commit

Permalink
Search hook fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pogseal committed Aug 26, 2024
1 parent e6a57f9 commit 1e183c5
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/_custom/hooks/search-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ export const afterChangeSearchSyncHook: CollectionAfterChangeHook = async ({

//Due to the way Payload handles depth in relationships, we need to fetch the icon URL if it exists
const { url: iconUrl } = doc?.icon?.url
? doc?.icon
? { url: doc?.icon?.url }
: doc?.icon
? await payload.findByID({
collection: "images",
id: doc?.icon,
depth: 0,
})
: null;
: { url: null };

await typesensePrivateClient
.collections("entries")
Expand Down
11 changes: 10 additions & 1 deletion app/db/collections/collections/collections-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,16 @@ export const collectionsAfterChangeHook: CollectionAfterChangeHook = async ({
doc?.site?.domain ? doc?.site?.domain : `${doc?.site?.slug}.mana.wiki`
}${collectionRelativeURL}`;

const iconUrl = doc?.icon?.url;
//Due to the way Payload handles depth in relationships, we need to fetch the icon URL if it exists
const { url: iconUrl } = doc?.icon?.url
? { url: doc?.icon?.url }
: doc?.icon
? await payload.findByID({
collection: "images",
id: doc?.icon,
depth: 0,
})
: { url: null };

await typesensePrivateClient
.collections("collections")
Expand Down
10 changes: 9 additions & 1 deletion app/db/collections/custom-pages/custom-pages-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ export const customPagesAfterChangeHook: CollectionAfterChangeHook = async ({

const description = doc?.description;

const iconUrl = doc?.icon?.url;
const { url: iconUrl } = doc?.icon?.url
? { url: doc?.icon?.url }
: doc?.icon
? await payload.findByID({
collection: "images",
id: doc?.icon,
depth: 0,
})
: { url: null };

await typesensePrivateClient
.collections("customPages")
Expand Down
11 changes: 10 additions & 1 deletion app/db/collections/entries/entries-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,16 @@ export const entriesAfterChangeHook: CollectionAfterChangeHook = async ({
doc?.site?.domain ? doc?.site?.domain : `${doc?.site?.slug}.mana.wiki`
}${entryRelativeURL}`;

const iconUrl = doc?.icon?.url;
const { url: iconUrl } = doc?.icon?.url
? { url: doc?.icon?.url }
: doc?.icon
? await payload.findByID({
collection: "images",
id: doc?.icon,
depth: 0,
})
: { url: null };

const description = doc?.collectionEntity?.name;

await typesensePrivateClient
Expand Down
11 changes: 10 additions & 1 deletion app/db/collections/posts/posts-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ export const postsAfterChangeHook: CollectionAfterChangeHook = async ({
: `${doc?.site?.slug}.mana.wiki`
}${postRelativeURL}`;

const bannerUrl = doc?.banner?.url;
//Due to the way Payload handles depth in relationships, we need to fetch the icon URL if it exists
const { url: bannerUrl } = doc?.banner?.url
? { url: doc?.banner?.url }
: doc?.banner
? await payload.findByID({
collection: "images",
id: doc?.banner,
depth: 0,
})
: { url: null };
const description = doc?.subtitle;

await typesensePrivateClient
Expand Down
4 changes: 3 additions & 1 deletion app/db/collections/users/users.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export const Users: CollectionConfig = {
}/verify?token=${token}`;

return `
<span>Hey ${user.email}, thanks for registering at Mana.</span>
<span>Hey ${user.email}, thanks for registering at ${
process.env.HOST_DOMAIN ?? "mana.wiki"
}</span>
<br><br>
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_user+/components/UserMenuItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function UserMenuItems() {
<div className="space-y-1.5 flex-grow">
<UserMenuLink text="Account" icon="user" to="/user/account" />
<UserMenuLink text="Appearance" icon="palette" to="/user/appearance" />
<UserMenuLink text="Billing" icon="credit-card" to="/user/billing" />
{/* <UserMenuLink text="Billing" icon="credit-card" to="/user/billing" /> */}
</div>
);
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"clean": "shx rm -rf node_modules dist build public/build",
"seed:core": "cross-env PAYLOAD_CONFIG_PATH=./app/db/payload.config.ts ts-node -T app/_custom/seed/index.ts",
"seed:custom": "cross-env PAYLOAD_CONFIG_PATH=./app/db/payload.custom.config.ts ts-node -T app/_custom/seed/index.ts",
"resave": "cross-env PAYLOAD_CONFIG_PATH=./app/db/payload.custom.config.ts ts-node -T ./scripts/resaveCollection",
"resaveCore": "cross-env PAYLOAD_CONFIG_PATH=./app/db/payload.config.ts ts-node -T ./scripts/resaveCollection",
"resaveCustom": "cross-env PAYLOAD_CONFIG_PATH=./app/db/payload.custom.config.ts ts-node -T ./scripts/resaveCollection",
"typesense": "cross-env ts-node -T ./scripts/typesenseActions",
"postinstall": "patch-package"
},
Expand Down
4 changes: 2 additions & 2 deletions scripts/resaveCollection.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Payload from "payload";

import { manaSlug } from "../app/utils/url-slug";
// import { manaSlug } from "../app/utils/url-slug";

require("dotenv").config();

Expand Down Expand Up @@ -41,7 +41,7 @@ const resaveCollection = async () => {
await payload.update({
collection: collectionSlug,
id,
depth: 0,
depth: 2,
data: {
updatedAt: new Date(),
// slug: manaSlug(result.name),
Expand Down

0 comments on commit 1e183c5

Please sign in to comment.