Skip to content

Commit 5370a9f

Browse files
authored
Merge pull request #536 from mwskwong/canary
Canary
2 parents 37fa0bc + eca3c42 commit 5370a9f

File tree

5 files changed

+15
-37
lines changed

5 files changed

+15
-37
lines changed

README.md

+6-28
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<h1 align="center">
2-
<a href="https://mwskwong.com" rel="noopener" target="_blank">mwskwong.com</a>
3-
</h1>
1+
# [mwskwong.com](https://mwskwong.com)
42

53
## Greetings 👋.
64

@@ -16,38 +14,18 @@ Welcome to the source code of [mwskwong.com](https://mwskwong.com). You can see
1614

1715
2. Delete the untargeted canary environment (i.e. the one previously targeted by `master`) and add a new one.
1816

19-
- Environment ID naming: `canary_YYYY-MM-DDTHH.mm.ss.SSSZ`
17+
- Environment ID naming: `canary_YYYY-MM-DDTHH-mm-ss-SSSZ`
2018

2119
```js
22-
`canary_${new Date().toISOString().replaceAll(":", ".")}`;
20+
navigator.clipboard.writeText(
21+
`canary_${new Date().toISOString().replaceAll(":", "-")}`
22+
);
2323
```
2424

25-
- Cloned from: `development` environment
25+
- Cloned from: `master` environment
2626

2727
3. Update the **Environments** of the `canary` API key, check the newly added canary environment
2828

2929
3. In [Vercel](https://vercel.com), replace the value of environment variable `CONTENTFUL_ENVIRONMENT` of the **Preview** environment to the Contentful Environment ID defined in step 2.ii.
3030

3131
4. Merge/enable auto merge for the PR.
32-
33-
## Preview Deployment
34-
35-
1. Create a PR to `canary` (optional)
36-
37-
2. In [Contentful](https://app.contentful.com/)
38-
39-
1. Delete the latest canary environment and add a new one.
40-
41-
- Environment ID naming: `canary_YYYY-MM-DDTHH.mm.ss.SSSZ`
42-
43-
```js
44-
`canary_${new Date().toISOString().replaceAll(":", ".")}`;
45-
```
46-
47-
- Cloned from: `development` environment
48-
49-
2. Update the **Environments** of the `canary` API key, check the newly added canary environment
50-
51-
3. Perform step 3 of [PROD Deployment](#prod-deployment)
52-
53-
4. Merge the PR or push code changes to `canary` directly

src/app/layout.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ export const generateMetadata = async () =>
8989
type: "website",
9090
siteName,
9191
},
92-
robots: { "max-image-preview": "large" },
9392
icons: {
9493
icon: await Promise.all(
9594
iconSizes.map(async (size) => {

src/app/robots.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { type MetadataRoute } from "next";
22

3-
import { siteUrl } from "@/constants/site-config";
3+
import { routes, siteUrl } from "@/constants/site-config";
44

55
const robots = () =>
66
({
77
rules: {
88
userAgent: "*",
9-
disallow: process.env.VERCEL_ENV === "production" ? "/params" : "/",
9+
disallow: process.env.VERCEL_ENV === "production" ? routes.params.pathname : "/",
1010
},
1111
sitemap: `${siteUrl}/sitemap.xml`,
1212
}) satisfies MetadataRoute.Robots;

src/components/blog-post/copy-link-button.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const CopyLinkButton: FC<CopyLinkButtonProps> = (props) => {
2121
color="gray"
2222
variant="ghost"
2323
onClick={async () => {
24-
await navigator.clipboard.writeText(`${siteUrl}${pathname}`);
24+
await navigator.clipboard.writeText(siteUrl + pathname);
2525
setCopied(true);
2626
timeout.current = setTimeout(() => setCopied(false), 1000);
2727
}}

src/constants/site-config.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const routes = {
1717
params: { name: "Parameters", pathname: "/_params" },
1818
} as const satisfies Record<string, Route>;
1919

20+
// ref: https://nextjs.org/docs/app/api-reference/functions/generate-metadata#default-value
2021
const getSiteUrl = () => {
2122
if (
2223
process.env.NEXT_PUBLIC_VERCEL_ENV === "production" &&
@@ -25,11 +26,11 @@ const getSiteUrl = () => {
2526
return `https://${process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL}`;
2627
}
2728

28-
if (
29-
process.env.NEXT_PUBLIC_VERCEL_ENV &&
30-
process.env.NEXT_PUBLIC_VERCEL_URL
31-
) {
32-
return `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`;
29+
const previewOrigin =
30+
process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL ??
31+
process.env.NEXT_PUBLIC_VERCEL_URL;
32+
if (process.env.NEXT_PUBLIC_VERCEL_ENV === "preview" && previewOrigin) {
33+
return `https://${previewOrigin}`;
3334
}
3435

3536
return `http://localhost:${process.env.PORT ?? 3000}`;

0 commit comments

Comments
 (0)