Skip to content

Commit

Permalink
Merge pull request #2 from roqqetmedia/feat/update-seo-sitemap-robots
Browse files Browse the repository at this point in the history
update seo - add sitemap and robots built-in functions
  • Loading branch information
alipiry authored Aug 7, 2023
2 parents bf903b6 + 7db6904 commit cf73e56
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 32 deletions.
1 change: 1 addition & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
APP_ENV=dev
SITE_URL=http://localhost:3000
7 changes: 0 additions & 7 deletions next-sitemap.config.js

This file was deleted.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"postbuild": "next-sitemap",
"start": "next start",
"lint": "next lint",
"lint:strict": "eslint --max-warnings=0 src",
Expand All @@ -17,7 +16,6 @@
"dependencies": {
"framer-motion": "10.15.0",
"next": "13.4.12",
"next-sitemap": "4.1.8",
"react": "18.2.0",
"react-dom": "18.2.0",
"sharp": "0.32.4"
Expand Down
Binary file added public/images/og.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 49 additions & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,59 @@ import { Montserrat } from "next/font/google";
import { twMerge } from "tailwind-merge";
import Header from "@/ui/header/header";
import Footer from "@/ui/footer/footer";
import { APP_ENV, SITE_URL } from "@/config";
import "@/app/globals.css";

export const metadata = {
title: "Roqqet Media",
viewport: {
width: "device-width",
initialScale: 1,
maximumScale: 1,
},
title: {
template: "%s | Roqqet Media",
default: "Roqqet Media",
},
description: "NextJS starter template",
keywords: ["Roqqet Media", "Nextjs", "Starter"],
keywords: ["Roqqet Media", "Nextjs", "Starter", "App Router"],
metadataBase: new URL(SITE_URL),
openGraph: {
title: "Roqqet Media",
description: "NextJS starter template",
url: SITE_URL,
siteName: "Roqqet Media",
images: [
{
url: "/og.png",
width: 2800,
height: 1600,
alt: "Roqqet Media",
},
],
locale: "en_UK",
type: "website",
},
twitter: {
card: "summary_large_image",
title: "Roqqet Media",
description: "NextJS starter template",
site: "@roqqetmedia",
images: ["/og.png"],
},
robots: {
index: APP_ENV === "production",
follow: APP_ENV === "production",
"max-image-preview": "large",
"max-video-preview": -1,
"max-snippet": -1,
googleBot: {
index: APP_ENV === "production",
follow: APP_ENV === "production",
"max-image-preview": "large",
"max-video-preview": -1,
"max-snippet": -1,
},
},
};

const montserrat = Montserrat({
Expand Down
2 changes: 2 additions & 0 deletions src/config/env/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const APP_ENV = process.env.APP_ENV || "dev";
export const SITE_URL = process.env.SITE_URL || "";
1 change: 1 addition & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./env";
21 changes: 21 additions & 0 deletions src/robots.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { MetadataRoute } from "next";
import { APP_ENV, SITE_URL } from "@/config";

export default function robots(): MetadataRoute.Robots {
if (APP_ENV === "production") {
return {
rules: {
userAgent: "*",
allow: "/",
},
sitemap: `${SITE_URL}/sitemap.xml`,
};
}

return {
rules: {
userAgent: "*",
disallow: "/",
},
};
}
13 changes: 13 additions & 0 deletions src/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { MetadataRoute } from "next";
import { APP_ENV, SITE_URL } from "@/config";

export default function sitemap(): MetadataRoute.Sitemap {
if (APP_ENV === "production") {
return [""].map((route) => ({
url: `${SITE_URL}${route}`,
lastModified: new Date(),
}));
}

return [];
}
22 changes: 1 addition & 21 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
dependencies:
regenerator-runtime "^0.13.11"

"@corex/deepmerge@^4.0.43":
version "4.0.43"
resolved "https://registry.yarnpkg.com/@corex/deepmerge/-/deepmerge-4.0.43.tgz#9bd42559ebb41cc5a7fb7cfeea5f231c20977dca"
integrity sha512-N8uEMrMPL0cu/bdboEWpQYb/0i2K5Qn8eCsxzOmxSggJbbQte7ljMRoXm917AbntqTGOzdTu+vP3KOOzoC70HQ==

"@emotion/is-prop-valid@^0.8.2":
version "0.8.8"
resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-0.8.8.tgz#db28b1c4368a259b60a97311d6a952d4fd01ac1a"
Expand Down Expand Up @@ -129,11 +124,6 @@
resolved "https://registry.yarnpkg.com/@next/env/-/env-13.4.12.tgz#0b88115ab817f178bf9dc0c5e7b367277595b58d"
integrity sha512-RmHanbV21saP/6OEPBJ7yJMuys68cIf8OBBWd7+uj40LdpmswVAwe1uzeuFyUsd6SfeITWT3XnQfn6wULeKwDQ==

"@next/env@^13.4.3":
version "13.4.10"
resolved "https://registry.yarnpkg.com/@next/env/-/env-13.4.10.tgz#8b17783d2c09be126bbde9ff1164566517131bff"
integrity sha512-3G1yD/XKTSLdihyDSa8JEsaWOELY+OWe08o0LUYzfuHp1zHDA8SObQlzKt+v+wrkkPcnPweoLH1ImZeUa0A1NQ==

"@next/eslint-plugin-next@13.4.12":
version "13.4.12"
resolved "https://registry.yarnpkg.com/@next/eslint-plugin-next/-/eslint-plugin-next-13.4.12.tgz#e75c4fedd0324d4f8fa8be2eb446270a462d3092"
Expand Down Expand Up @@ -2106,7 +2096,7 @@ minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2:
dependencies:
brace-expansion "^1.1.7"

minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2.6, minimist@^1.2.8:
minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2.6:
version "1.2.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c"
integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==
Expand Down Expand Up @@ -2155,16 +2145,6 @@ natural-compare@^1.4.0:
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==

next-sitemap@4.1.8:
version "4.1.8"
resolved "https://registry.yarnpkg.com/next-sitemap/-/next-sitemap-4.1.8.tgz#c1392878e1119039c601fa5c07f3e02750d21a06"
integrity sha512-XAXpBHX4o89JfMgvrm0zimlZwpu2iBPXHpimJMUrqOZSc4C2oB1Lv89mxuVON9IE8HOezaM+w4GjJxcYCuGPTQ==
dependencies:
"@corex/deepmerge" "^4.0.43"
"@next/env" "^13.4.3"
fast-glob "^3.2.12"
minimist "^1.2.8"

next@13.4.12:
version "13.4.12"
resolved "https://registry.yarnpkg.com/next/-/next-13.4.12.tgz#809b21ea0aabbe88ced53252c88c4a5bd5af95df"
Expand Down

0 comments on commit cf73e56

Please sign in to comment.