diff --git a/.env.local.example b/.env.local.example index db9ffe0..9fb2be0 100644 --- a/.env.local.example +++ b/.env.local.example @@ -1 +1,2 @@ +APP_ENV=dev SITE_URL=http://localhost:3000 diff --git a/next-sitemap.config.js b/next-sitemap.config.js deleted file mode 100644 index 5b7ab26..0000000 --- a/next-sitemap.config.js +++ /dev/null @@ -1,7 +0,0 @@ -/** @type {import('next-sitemap').IConfig} */ - -module.exports = { - siteUrl: process.env.SITE_URL || "https://nextjs-starter.roqqet.media", - generateRobotsTxt: true, // (optional) - // ...other options -}; diff --git a/package.json b/package.json index d89411e..7243eef 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" diff --git a/public/images/og.png b/public/images/og.png new file mode 100644 index 0000000..15adfc4 Binary files /dev/null and b/public/images/og.png differ diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 444ee21..64c6305 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -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({ diff --git a/src/config/env/index.ts b/src/config/env/index.ts new file mode 100644 index 0000000..d2e2748 --- /dev/null +++ b/src/config/env/index.ts @@ -0,0 +1,2 @@ +export const APP_ENV = process.env.APP_ENV || "dev"; +export const SITE_URL = process.env.SITE_URL || ""; diff --git a/src/config/index.ts b/src/config/index.ts new file mode 100644 index 0000000..77b0d3c --- /dev/null +++ b/src/config/index.ts @@ -0,0 +1 @@ +export * from "./env"; diff --git a/src/robots.ts b/src/robots.ts new file mode 100644 index 0000000..3c5602b --- /dev/null +++ b/src/robots.ts @@ -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: "/", + }, + }; +} diff --git a/src/sitemap.ts b/src/sitemap.ts new file mode 100644 index 0000000..7941ed1 --- /dev/null +++ b/src/sitemap.ts @@ -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 []; +} diff --git a/yarn.lock b/yarn.lock index 3691b8b..f8dee98 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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" @@ -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== @@ -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"