Skip to content

Commit

Permalink
Added window.location.origin handling, fixed dropdown spacing issue, …
Browse files Browse the repository at this point in the history
…and changed placeholder text
  • Loading branch information
calvadev committed Feb 23, 2025
1 parent 258a120 commit e6af19c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion components/combined-contact-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default function CombinedContactForm({
fullWidth={true}
label="Contact"
labelPlacement="inside"
placeholder="shopstr@shopstr.store"
placeholder="@shopstr"
isInvalid={isErrored}
errorMessage={errorMessage}
// controller props
Expand Down
2 changes: 1 addition & 1 deletion components/contact-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default function ContactForm({
fullWidth={true}
label="Contact"
labelPlacement="inside"
placeholder="shopstr@shopstr.store"
placeholder="@shopstr"
isInvalid={isErrored}
errorMessage={errorMessage}
// controller props
Expand Down
21 changes: 15 additions & 6 deletions components/dynamic-meta-head.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Head from "next/head";
import { useEffect, useState } from "react";
import { useRouter } from "next/router";
import { NostrEvent, ShopSettings } from "@/utils/types/types";
import parseTags from "./utility/product-parser-functions";
Expand All @@ -12,6 +13,7 @@ type MetaTagsType = {
};

const getMetaTags = (
windowOrigin: string,
pathname: string,
query: { productId?: string[]; npub?: string[] },
productEvents: NostrEvent[],
Expand All @@ -21,7 +23,7 @@ const getMetaTags = (
title: "Shopstr",
description: "Shop freely.",
image: "/shopstr-2000x2000.png",
url: "https://shopstr.store",
url: `${windowOrigin}`,
};

if (pathname.startsWith("/listing/")) {
Expand All @@ -46,14 +48,14 @@ const getMetaTags = (
description:
productData.summary || "Check out this product on Shopstr!",
image: productData.images?.[0] || "/shopstr-2000x2000.png",
url: `https://shopstr.store/listing/${naddr}`,
url: `${windowOrigin}/listing/${naddr}`,
};
}
return {
...defaultTags,
title: "Shopstr Listing",
description: "Check out this listing on Shopstr!",
url: `https://shopstr.store/listing/${naddr}`,
url: `${windowOrigin}/listing/${naddr}`,
};
}
} else if (pathname.includes("/npub")) {
Expand All @@ -70,14 +72,14 @@ const getMetaTags = (
description:
shopInfo.content.about || "Check out this shop on Shopstr!",
image: shopInfo.content.ui.picture || "/shopstr-2000x2000.png",
url: `https://shopstr.store/marketplace/${npub}`,
url: `${windowOrigin}/marketplace/${npub}`,
};
}
return {
...defaultTags,
title: "Shopstr Shop",
description: "Check out this shop on Shopstr!",
url: `https://shopstr.store/marketplace/${npub}`,
url: `${windowOrigin}/marketplace/${npub}`,
};
}

Expand All @@ -92,7 +94,14 @@ const DynamicHead = ({
shopEvents: Map<string, ShopSettings>;
}) => {
const router = useRouter();
const [origin, setOrigin] = useState("");

useEffect(() => {
setOrigin(window.location.origin);
}, []);

const metaTags = getMetaTags(
origin ? origin : "https://shopstr.market",
router.pathname,
router.query,
productEvents,
Expand All @@ -113,7 +122,7 @@ const DynamicHead = ({
<meta property="og:description" content={metaTags.description} />
<meta property="og:image" content={metaTags.image} />
<meta name="twitter:card" content="summary_large_image" />
<meta property="twitter:domain" content="shopstr.store" />
<meta property="twitter:domain" content={origin} />
<meta property="twitter:url" content={metaTags.url} />
<meta name="twitter:title" content={metaTags.title} />
<meta name="twitter:description" content={metaTags.description} />
Expand Down
8 changes: 5 additions & 3 deletions components/home/marketplace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ export function MarketplacePage({
</div>
</div>
) : (
<>
<div className="flex flex-row gap-2 pb-3">
<div className="flex flex-col gap-2 pb-3 sm:flex-row">
<div className="w-full">
<Input
className="mt-2 text-light-text dark:text-dark-text"
isClearable
Expand All @@ -360,6 +360,8 @@ export function MarketplacePage({
setSelectedSearch(value);
}}
></Input>
</div>
<div className="flex w-full flex-row gap-2 pb-3">
<Select
className="mt-2 text-light-text dark:text-dark-text"
label="Categories"
Expand Down Expand Up @@ -400,7 +402,7 @@ export function MarketplacePage({
/>
) : null}
</div>
</>
</div>
)}
</div>
<div className="flex">
Expand Down
6 changes: 3 additions & 3 deletions components/utility/nostr-helper-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export async function DeleteEvent(
let deletionEvent = await createNostrDeleteEvent(
event_ids_to_delete,
userPubkey,
"user deletion request from shopstr.store",
"NIP-99 listing deletion request",
);

await finalizeAndSendNostrEvent(deletionEvent, passphrase);
Expand Down Expand Up @@ -346,8 +346,8 @@ export async function PostListing(
tags: [
["d", handlerDTag],
["k", "30402"],
["web", "https://shopstr.store/marketplace/<bech-32>", "npub"],
["web", "https://shopstr.store/listing/<bech-32>", "naddr"],
["web", `${window.location.origin}/marketplace/<bech-32>`, "npub"],
["web", `${window.location.origin}/listing/<bech-32>`, "naddr"],
],
content: "",
created_at: Math.floor(Date.now() / 1000),
Expand Down

0 comments on commit e6af19c

Please sign in to comment.