-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update og route to decrease size * adding view count * update pnpm lockfile * update package.json for reach and react-dom * update Typescript * remove unused comments * Update environment variables in turbo.json Reference: https://turbo.build/repo/docs/crafting-your-repository/using-environment-variables
- Loading branch information
1 parent
737bb4b
commit 4e3ad1b
Showing
16 changed files
with
662 additions
and
606 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,4 +45,5 @@ apps/**/dist | |
.dccache | ||
|
||
# ENV | ||
.env | ||
.env | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { kv } from "@vercel/kv"; | ||
import React from "react"; | ||
|
||
import { Text } from "@thugga/ui"; | ||
|
||
async function recordView(slug: string) { | ||
// Get the formatter | ||
const formatter = Intl.NumberFormat("en", { notation: "compact" }); | ||
|
||
// Create keys | ||
const viewKey = ["pageviews", "essays", slug].join(":"); | ||
|
||
await kv.incr(viewKey); | ||
const viewCount = (await kv.get<number>(viewKey)) ?? 0; | ||
return { | ||
message: "View Added", | ||
status: 202, | ||
views: formatter.format(viewCount), | ||
}; | ||
} | ||
|
||
export default async function ViewsCounter({ essay }: { essay: string }) { | ||
const views = await recordView(essay); | ||
return <Text variant="small">{views?.views || 0} views</Text>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,10 +22,10 @@ | |
"npm": ">=7.0.0", | ||
"node": ">=20.0.0" | ||
}, | ||
"packageManager": "[email protected]", | ||
"private": true, | ||
"workspaces": [ | ||
"apps/*", | ||
"packages/*" | ||
], | ||
"packageManager": "[email protected]" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.