Skip to content

Commit

Permalink
feat: add canonicals, robots.txt and sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniDigger committed Jul 20, 2024
1 parent 6e2408c commit 9e95fae
Show file tree
Hide file tree
Showing 24 changed files with 67 additions and 23 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enable-pre-post-scripts=true
9 changes: 9 additions & 0 deletions next-sitemap.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import('next-sitemap').IConfig} */

const dev = process.env.NODE_ENV !== 'production';

module.exports = {
siteUrl: dev ? 'http://localhost:3000' : 'https://papermc.io',
exclude: ["/downloads/all"],
generateIndexSitemap: false,
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"postbuild": "next-sitemap",
"start": "next start",
"lint": "next lint"
},
Expand All @@ -18,6 +19,7 @@
"@headlessui/react": "2.1.2",
"clsx": "2.1.1",
"next": "13.5.4",
"next-sitemap": "^4.2.3",
"react": "18.3.1",
"react-dom": "18.3.1",
"sharp": "^0.33.4",
Expand Down
40 changes: 21 additions & 19 deletions pnpm-lock.yaml

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

1 change: 1 addition & 0 deletions public/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sitemap.xml
7 changes: 6 additions & 1 deletion public/robots.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
User-agent: *
Disallow: /downloads/all
Disallow: /repository/
Disallow: /repo/
Disallow: /api/
Allow: /
Disallow: /downloads/all

Sitemap: https://papermc.io/sitemap.xml
4 changes: 2 additions & 2 deletions src/components/layout/SoftwareDownload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const SoftwareDownload = ({
const [isStable, setStable] = useState(true);
const version = isStable
? project.latestStableVersion
: project.latestExperimentalVersion ?? project.latestStableVersion;
: (project.latestExperimentalVersion ?? project.latestStableVersion);
const { data: builds } = useVersionBuilds(id, version);
const latestBuild = builds && builds.builds[builds.builds.length - 1];

Expand Down Expand Up @@ -61,7 +61,7 @@ const SoftwareDownload = ({
</span>
</h2>
<p className="text-xl mt-4">
{isStable ? description : experimentalWarning ?? description}
{isStable ? description : (experimentalWarning ?? description)}
</p>
<div className="flex flex-col gap-4 mt-8">
<SoftwareDownloadButton
Expand Down
10 changes: 9 additions & 1 deletion src/components/util/SEO.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,24 @@ export interface SEOProps {
title: string;
description: string;
keywords: string[];
canonical: string;
}

const SEO = ({ title, description, keywords }: SEOProps): ReactElement => {
const SEO = ({
title,
description,
keywords,
canonical,
}: SEOProps): ReactElement => {
return (
<Head>
<title>{title + " | PaperMC"}</title>

<meta name="description" content={description} />
<meta name="keywords" content={keywords.join(", ")} />

<link rel="canonical" href={`https://papermc.io` + canonical} />

<meta property="og:type" content="website" />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
Expand Down
1 change: 1 addition & 0 deletions src/pages/community/guidelines.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const CommunityGuidelines: NextPage = () => (
title="Community Guidelines"
description="Community Guidelines for the PaperMC community."
keywords={["papermc", "paper", "minecraft", "community", "guidelines"]}
canonical="/community/guidelines"
/>
<header className="max-w-7xl mx-auto px-4 pt-32 pb-16">
<h1 className="font-medium leading-normal lg:(text-5xl leading-normal) text-4xl">
Expand Down
1 change: 1 addition & 0 deletions src/pages/community/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const CommunityIndex: NextPage = () => (
title="Community"
description="We're happy to have you as a part of the PaperMC community!"
keywords={["papermc", "paper", "minecraft", "sponsor", "community"]}
canonical="/community"
/>
<header className="max-w-7xl flex flex-row mx-auto px-4 pt-32 pb-16 lg:(pt-48 pb-32) gap-16">
<div className="flex-1">
Expand Down
1 change: 1 addition & 0 deletions src/pages/contribute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const Contribute: NextPage = () => (
title="Contributing"
description="Without contributors our projects wouldn't be possible. Find out how you can help."
keywords={["papermc", "paper", "minecraft", "sponsor", "contributing"]}
canonical="/contribute"
/>
<header className="max-w-7xl flex flex-row mx-auto px-4 pt-32 pb-16 lg:(pt-48 pb-32) gap-16">
<div className="flex-1">
Expand Down
1 change: 1 addition & 0 deletions src/pages/downloads/all.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const LegacyDownloads: NextPage<LegacyDownloadProps> = ({
title="Build explorer"
description="Build explorer for PaperMC projects. Proceed with caution!"
keywords={[]}
canonical="/downloads/all"
/>
<div className="flex flex-col h-screen">
<div className="h-16" />
Expand Down
1 change: 1 addition & 0 deletions src/pages/downloads/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const Downloads: NextPage = () => {
"waterfall",
"downloads",
]}
canonical="/downloads"
/>
<header className="max-w-4xl flex flex-col items-center mx-auto px-4 pt-32 pb-16 lg:(pt-48 pb-26) gap-2">
<h1 className="font-medium leading-normal lg:(text-5xl leading-normal) text-4xl">
Expand Down
1 change: 1 addition & 0 deletions src/pages/downloads/paper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const PaperDownloads = ({ project }: ProjectProps): ReactElement => {
"downloads",
"jar",
]}
canonical="/downloads/paper"
/>
<SoftwareDownload
id="paper"
Expand Down
1 change: 1 addition & 0 deletions src/pages/downloads/velocity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const VelocityDownloads = ({ project }: ProjectProps): ReactElement => {
"downloads",
"jar",
]}
canonical="/downloads/velocity"
/>
<SoftwareDownload
id="velocity"
Expand Down
1 change: 1 addition & 0 deletions src/pages/downloads/waterfall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const WaterfallDownloads = ({ project }: ProjectProps): ReactElement => {
"downloads",
"jar",
]}
canonical="/downloads/waterfall"
/>
<SoftwareDownload
id="waterfall"
Expand Down
1 change: 1 addition & 0 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const Home: NextPage<ProjectProps> = ({ project }) => {
description="PaperMC is a Minecraft software organization focusing on improving
the game’s ecosystem with faster and more secure software."
keywords={["papermc", "paper", "velocity", "minecraft", "performance"]}
canonical="/"
/>
<header className="max-w-7xl flex flex-row mx-auto px-4 pt-32 pb-26 lg:(pt-48 pb-46)">
<div className="flex-1">
Expand Down
1 change: 1 addition & 0 deletions src/pages/javadocs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const Javadocs: NextPage<JavadocProps> = ({
"velocity",
"waterfall",
]}
canonical="/javadocs"
/>
<header className="max-w-7xl flex flex-col items-center mx-auto px-4 pt-32 pb-16 lg:(pt-48 pb-26) gap-2">
<h1 className="font-medium leading-normal lg:(text-5xl leading-normal) text-4xl">
Expand Down
1 change: 1 addition & 0 deletions src/pages/software/folia/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const FoliaHome = ({ project }: HangarProjectProps): ReactElement => {
"multithreading",
"fork",
]}
canonical="/software/folia"
/>
<SoftwareHeader
id="folia"
Expand Down
1 change: 1 addition & 0 deletions src/pages/software/paper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const PaperHome = ({
"spigot",
"fork",
]}
canonical="/software/paper"
/>
<SoftwareHeader
id="paper"
Expand Down
1 change: 1 addition & 0 deletions src/pages/software/velocity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const VelocityHome = ({
"performance",
"bungeecord",
]}
canonical="/software/velocity"
/>
<SoftwareHeader
id="velocity"
Expand Down
1 change: 1 addition & 0 deletions src/pages/software/waterfall/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const WaterfallHome = ({ project }: HangarProjectProps): ReactElement => {
"bungeecord",
"fork",
]}
canonical="/software/waterfall"
/>
<SoftwareHeader
id="waterfall"
Expand Down
1 change: 1 addition & 0 deletions src/pages/sponsors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const Sponsors: NextPage = () => {
title="Sponsors"
description="Without contributors our projects wouldn't be possible. Find out how you can help."
keywords={["papermc", "paper", "minecraft", "sponsor", "contributing"]}
canonical="/sponsors"
/>
<header className="max-w-7xl flex flex-row mx-auto px-4 pt-32 pb-16 lg:(pt-48 pb-32) gap-16">
<div className="flex-1">
Expand Down
Loading

0 comments on commit 9e95fae

Please sign in to comment.