Skip to content

Commit

Permalink
feat(docs): metadata + sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyr33x authored Feb 5, 2025
2 parents 9aea165 + dcdcee9 commit 8bb7222
Show file tree
Hide file tree
Showing 20 changed files with 136 additions and 47 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Initialize the Rehooks configuration easily.

<h1 align="center">📚 Documentation</h1>
<p align="center">
Check out the <a href="https://rehooks.pyr33x.ir">documentation</a> for more information.
Check out the <a href="https://rehooks.dev">documentation</a> for more information.
</p>

<h1 align="center">🧾 License</h1>
Expand Down
7 changes: 6 additions & 1 deletion apps/docs/app/(docs)/docs/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import {
DocsDescription,
} from "fumadocs-ui/page";
import { source, openapi } from "@/lib/docs/source";
import defaultMdxComponents from "fumadocs-ui/mdx";
import { metadataImage } from "@/lib/docs/metadata";
import defaultMdxComponents from "fumadocs-ui/mdx";
import { notFound } from "next/navigation";
import { DOCS_URL } from "@rehooks/utils";

export default async function Page({
params,
Expand Down Expand Up @@ -46,5 +47,9 @@ export async function generateMetadata(props: {
return metadataImage.withImage(page.slugs, {
title: page.data.title,
description: page.data.description,
openGraph: {
siteName: "Rehooks",
url: `${DOCS_URL}/docs/${page.slugs.join("/")}`,
},
});
}
14 changes: 14 additions & 0 deletions apps/docs/app/docs-og/[...slug]/route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { metadataImage } from "@/lib/docs/metadata";
import { generateOGImage } from "fumadocs-ui/og";

export const GET = metadataImage.createAPI((page) => {
return generateOGImage({
title: page.data.title,
description: page.data.description,
site: "Rehooks",
});
});

export function generateStaticParams() {
return metadataImage.generateParams();
}
11 changes: 11 additions & 0 deletions apps/docs/app/robots.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { MetadataRoute } from "next";

export default function robots(): MetadataRoute.Robots {
return {
rules: {
userAgent: "*",
allow: ["/", "/docs/cli", "/docs/api", "/blog"],
},
sitemap: "https://rehooks.dev",
};
}
44 changes: 44 additions & 0 deletions apps/docs/app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { source } from "@/lib/docs/source";
import { DOCS_URL } from "@rehooks/utils";
import type { MetadataRoute } from "next";

export const revalidate = false;

export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const url = (path: string) => new URL(path, DOCS_URL).toString();

return [
{
url: url("/"),
changeFrequency: "monthly",
priority: 1,
},
{
url: url("/docs/cli"),
changeFrequency: "weekly",
priority: 0.8,
},
{
url: url("/docs/api"),
changeFrequency: "weekly",
priority: 0.8,
},
{
url: url("/blog"),
changeFrequency: "monthly",
priority: 0.6,
},
...(await Promise.all(
source.getPages().map(async (page) => {
const { lastModified } = page.data;

return {
url: url(page.url),
lastModified: lastModified ? new Date(lastModified) : undefined,
changeFrequency: "weekly",
priority: 0.5,
} as MetadataRoute.Sitemap[number];
}),
)),
];
}
2 changes: 1 addition & 1 deletion apps/docs/content/blog/rehooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ Rehooks represents a shift in how we think about code reuse in React application

## Resources

- [Documentation](https://rehooks.pyr33x.ir)
- [Documentation](https://rehooks.dev)
- [Repository](https://github.com/pyr33x/rehooks)
5 changes: 5 additions & 0 deletions apps/docs/lib/docs/source.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { createOpenAPI, attachFile } from "fumadocs-openapi/server";
import { defineConfig } from "fumadocs-mdx/config";
import { docs, meta, blogPosts } from "@/.source";
import { createMDXSource } from "fumadocs-mdx";
import { loader } from "fumadocs-core/source";
import { icons } from "@rehooks/ui/icons";
import { createElement } from "react";

export default defineConfig({
lastModifiedTime: "git",
});

export const source = loader({
baseUrl: "/docs",
source: createMDXSource(docs, meta),
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/rehooksapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"servers": [
{
"url": "https://rehooks.pyr33x.ir/api",
"url": "https://rehooks.dev/api",
"description": "Production Server"
}
],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"husky": "^9.1.6",
"prettier": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.8",
"turbo": "^2.3.3",
"turbo": "^2.4.0",
"typescript": "5.6.3"
},
"packageManager": "[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Initialize the Rehooks configuration easily.

<h1 align="center">📚 Documentation</h1>
<p align="center">
Check out the <a href="https://rehooks.pyr33x.ir">documentation</a> for more information.
Check out the <a href="https://rehooks.dev">documentation</a> for more information.
</p>

<h1 align="center">🧾 License</h1>
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"preferGlobal": true,
"author": "Mehdi",
"homepage": "https://rehooks.pyr33x.ir",
"homepage": "https://rehooks.dev",
"repository": {
"type": "git",
"url": "git+https://github.com/Pyr33x/rehooks.git"
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const BASE_URL = "https://rehooks.pyr33x.ir/api";
export const BASE_URL = "https://rehooks.dev/api";
export const SRC_DIR_PLACEHOLDER = "./src/hooks";
export const DIR_PLACEHOLDER = "./hooks";
2 changes: 1 addition & 1 deletion packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function Component() {

<h1 align="center">Documentation 📚</h1>
<p align="center">
Check out the <a href="https://rehooks.pyr33x.ir">documentation</a> for more information.
Check out the <a href="https://rehooks.dev">documentation</a> for more information.
</p>

<h1 align="center">🧾 License</h1>
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@
"bugs": {
"url": "https://github.com/Pyr33x/rehooks/issues"
},
"homepage": "https://rehooks.pyr33x.ir"
"homepage": "https://rehooks.dev"
}
2 changes: 1 addition & 1 deletion packages/utils/src/api/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const openApiDocument = generator.generateDocument({
},
servers: [
{
url: "https://rehooks.pyr33x.ir/api",
url: "https://rehooks.dev/api",
description: "Production server",
},
],
Expand Down
1 change: 1 addition & 0 deletions packages/utils/src/constants/link.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export const GITHUB_LINK = "https://github.com/pyr33x/rehooks";
export const REHOOKS_NPM = "https://www.npmjs.com/package/rehooks-cli";
export const DOCS_URL = "https://rehooks.dev";
18 changes: 13 additions & 5 deletions packages/utils/src/constants/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@ import { keywords } from "./keywords";
import type { Metadata } from "next";

export const meta = {
metadataBase: new URL("https://rehooks.pyr33x.ir"),
metadataBase: new URL("https://rehooks.dev"),
/** OpenGraph */
openGraph: {
siteName: "Rehooks",
url: "https://rehooks.pyr33x.ir",
url: "https://rehooks.dev",
locale: "en_US",
images: "https://rehooks.pyr33x.ir/og.png",
images: "https://rehooks.dev/og.png",
creators: ["@pyr33x"],
description:
"A CLI to scaffold your react custom hooks, with a focus on performance, reusability, and type-safety.",
},
twitter: {
title: "Rehooks",
card: "summary_large_image",
creator: "@pyr33x",
site: "https://rehooks.pyr33x.ir",
images: "https://rehooks.pyr33x.ir/og.png",
site: "https://rehooks.dev",
images: "https://rehooks.dev/og.png",
description:
"A CLI to scaffold your react custom hooks, with a focus on performance, reusability, and type-safety.",
},
/** OpenGraph */

Expand Down Expand Up @@ -66,5 +71,8 @@ export const meta = {
"max-snippet": -1,
},
},
verification: {
google: process.env.GOOGLE_VERIFICATION_CODE ?? undefined,
},
/** Robots */
} satisfies Metadata;
2 changes: 1 addition & 1 deletion packages/utils/src/functions/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from "axios";

export const api = axios.create({
baseURL: "https://rehooks.pyr33x.ir/api",
baseURL: "https://rehooks.dev/api",
});

export const fetcher = async <T>(url: string) => {
Expand Down
58 changes: 29 additions & 29 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"build": {
"env": [
"UPSTASH_REDIS_REST_URL",
"UPSTASH_REDIS_REST_TOKEN"
"UPSTASH_REDIS_REST_TOKEN",
"GOOGLE_VERIFICATION_CODE"
],
"dependsOn": [
"^build"
Expand Down

1 comment on commit 8bb7222

@vercel
Copy link

@vercel vercel bot commented on 8bb7222 Feb 5, 2025

Choose a reason for hiding this comment

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

Please sign in to comment.