From 299cef20ef3cc9e97fe32b3dfa1faf71bb821b8a Mon Sep 17 00:00:00 2001 From: Aaron Yarborough <aaron@alienjungle.digital> Date: Wed, 13 Mar 2024 12:47:16 +0000 Subject: [PATCH] feat: add sitemap --- next-sitemap.config.cjs | 6 +++++ package-lock.json | 40 ++++++++++++++++++++++++++++++ package.json | 2 ++ public/robots.txt | 9 +++++++ public/sitemap-0.xml | 9 +++++++ public/sitemap.xml | 4 +++ src/components/Article/Article.jsx | 7 ++++++ 7 files changed, 77 insertions(+) create mode 100644 next-sitemap.config.cjs create mode 100644 public/robots.txt create mode 100644 public/sitemap-0.xml create mode 100644 public/sitemap.xml diff --git a/next-sitemap.config.cjs b/next-sitemap.config.cjs new file mode 100644 index 0000000..e47f671 --- /dev/null +++ b/next-sitemap.config.cjs @@ -0,0 +1,6 @@ +/** @type {import('next-sitemap').IConfig} */ +module.exports = { + siteUrl: process.env.SITE_URL || 'https://www.aaronjy.me', + generateRobotsTxt: true, // (optional) + // ...other options +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3918925..008a421 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "frontmatter-markdown-loader": "^3.7.0", "husky": "^9.0.11", "js-yaml": "^4.1.0", + "next-sitemap": "^4.2.3", "showdown": "^2.1.0", "standard": "^17.1.0" } @@ -1057,6 +1058,12 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/@corex/deepmerge": { + "version": "4.0.43", + "resolved": "https://registry.npmjs.org/@corex/deepmerge/-/deepmerge-4.0.43.tgz", + "integrity": "sha512-N8uEMrMPL0cu/bdboEWpQYb/0i2K5Qn8eCsxzOmxSggJbbQte7ljMRoXm917AbntqTGOzdTu+vP3KOOzoC70HQ==", + "dev": true + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -4824,6 +4831,39 @@ "react-dom": ">=16.0.0" } }, + "node_modules/next-sitemap": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/next-sitemap/-/next-sitemap-4.2.3.tgz", + "integrity": "sha512-vjdCxeDuWDzldhCnyFCQipw5bfpl4HmZA7uoo3GAaYGjGgfL4Cxb1CiztPuWGmS+auYs7/8OekRS8C2cjdAsjQ==", + "dev": true, + "funding": [ + { + "url": "https://github.com/iamvishnusankar/next-sitemap.git" + } + ], + "dependencies": { + "@corex/deepmerge": "^4.0.43", + "@next/env": "^13.4.3", + "fast-glob": "^3.2.12", + "minimist": "^1.2.8" + }, + "bin": { + "next-sitemap": "bin/next-sitemap.mjs", + "next-sitemap-cjs": "bin/next-sitemap.cjs" + }, + "engines": { + "node": ">=14.18" + }, + "peerDependencies": { + "next": "*" + } + }, + "node_modules/next-sitemap/node_modules/@next/env": { + "version": "13.5.6", + "resolved": "https://registry.npmjs.org/@next/env/-/env-13.5.6.tgz", + "integrity": "sha512-Yac/bV5sBGkkEXmAX5FWPS9Mmo2rthrOPRQQNfycJPkjUAUclomCPH7QFVCDQ4Mp2k2K1SSM6m0zrxYrOwtFQw==", + "dev": true + }, "node_modules/node-releases": { "version": "2.0.14", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", diff --git a/package.json b/package.json index d619210..45447ad 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "dev": "next dev", "server": "npx decap-server", "build": "next build", + "postbuild": "next-sitemap --config next-sitemap.config.cjs", "start": "next start", "link": "npx standard", "format": "npx standard --fix", @@ -30,6 +31,7 @@ "frontmatter-markdown-loader": "^3.7.0", "husky": "^9.0.11", "js-yaml": "^4.1.0", + "next-sitemap": "^4.2.3", "showdown": "^2.1.0", "standard": "^17.1.0" } diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..6a8d464 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,9 @@ +# * +User-agent: * +Allow: / + +# Host +Host: https://www.aaronjy.me + +# Sitemaps +Sitemap: https://www.aaronjy.me/sitemap.xml diff --git a/public/sitemap-0.xml b/public/sitemap-0.xml new file mode 100644 index 0000000..aa86fad --- /dev/null +++ b/public/sitemap-0.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"> +<url><loc>https://www.aaronjy.me/</loc><lastmod>2024-03-13T12:46:49.416Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url> +<url><loc>https://www.aaronjy.me/cv/</loc><lastmod>2024-03-13T12:46:49.417Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url> +<url><loc>https://www.aaronjy.me/fun/</loc><lastmod>2024-03-13T12:46:49.417Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url> +<url><loc>https://www.aaronjy.me/writing/</loc><lastmod>2024-03-13T12:46:49.417Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url> +<url><loc>https://www.aaronjy.me/fun/javascript-html5-tile-editor/</loc><lastmod>2024-03-13T12:46:49.417Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url> +<url><loc>https://www.aaronjy.me/writing/static-site-on-google-cloud/</loc><lastmod>2024-03-13T12:46:49.417Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url> +</urlset> \ No newline at end of file diff --git a/public/sitemap.xml b/public/sitemap.xml new file mode 100644 index 0000000..02435d6 --- /dev/null +++ b/public/sitemap.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> +<sitemap><loc>https://www.aaronjy.me/sitemap-0.xml</loc></sitemap> +</sitemapindex> \ No newline at end of file diff --git a/src/components/Article/Article.jsx b/src/components/Article/Article.jsx index 647350a..bd0f021 100644 --- a/src/components/Article/Article.jsx +++ b/src/components/Article/Article.jsx @@ -1,8 +1,15 @@ +import { NextSeo } from 'next-seo' import React from 'react' function Article ({ attributes, html }) { return ( <section> + <NextSeo title={attributes.title} description={attributes.desc} openGraph={ + { + title: attributes.title, + description: attributes.desc + } + } /> <article> <h1>{attributes.title}</h1> <p>{attributes.desc}</p>