Skip to content

Commit

Permalink
feat: integrate with next-sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
enjidev committed Dec 15, 2022
1 parent ad3d604 commit 671b80d
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

# next-sitemap
robots.txt
sitemap.xml
36 changes: 36 additions & 0 deletions next-sitemap.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/** @type {import('next-sitemap').IConfig} */
module.exports = {
siteUrl: 'https://www.enji.dev',
priority: 0.6,
generateRobotsTxt: true,
generateIndexSitemap: false,
transform: async (config, path) => {
const defaultValue = (priority) => {
return {
loc: path,
changefreq: config.changefreq,
priority: priority || config.priority,
lastmod: config.autoLastmod ? new Date().toISOString() : undefined,
alternateRefs: config.alternateRefs ?? [],
};
};

if (path === '/') {
return defaultValue(1.0);
}

if (path === '/blog') {
return defaultValue(0.9);
}

if (path === '/projects') {
return defaultValue(0.9);
}

if (path.indexOf('/work') === 0) {
return defaultValue(0.8);
}

return defaultValue();
},
};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"lint": "next lint",
"lint:types": "tsc --noEmit",
"lint:style": "prettier --check .",
"analyze": "cross-env ANALYZE=true yarn build"
"analyze": "cross-env ANALYZE=true yarn build",
"postbuild": "next-sitemap"
},
"dependencies": {
"@headlessui/react": "^1.7.4",
Expand Down Expand Up @@ -56,6 +57,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^8.0.0",
"mini-svg-data-uri": "^1.4.4",
"next-sitemap": "^3.1.42",
"postcss": "^8.4.18",
"prettier": "^2.7.1",
"prettier-plugin-tailwindcss": "^0.1.13",
Expand Down
3 changes: 0 additions & 3 deletions public/robots.txt

This file was deleted.

15 changes: 14 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
dependencies:
regenerator-runtime "^0.13.10"

"@corex/deepmerge@^4.0.29":
version "4.0.29"
resolved "https://registry.yarnpkg.com/@corex/deepmerge/-/deepmerge-4.0.29.tgz#af9debf07d7f6b0d2a9d04a266abf2c1418ed2f6"
integrity sha512-q/yVUnqckA8Do+EvAfpy7RLdumnBy9ZsducMUtZTvpdbJC7azEf1hGtnYYxm0QfphYxjwggv6XtH64prvS1W+A==

"@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 @@ -2542,7 +2547,7 @@ minimatch@^3.0.4, minimatch@^3.1.1, minimatch@^3.1.2:
dependencies:
brace-expansion "^1.1.7"

minimist@^1.2.0, minimist@^1.2.6:
minimist@^1.2.0, minimist@^1.2.6, minimist@^1.2.7:
version "1.2.7"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.7.tgz#daa1c4d91f507390437c6a8bc01078e7000c4d18"
integrity sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==
Expand Down Expand Up @@ -2587,6 +2592,14 @@ natural-compare@^1.4.0:
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==

next-sitemap@^3.1.42:
version "3.1.42"
resolved "https://registry.yarnpkg.com/next-sitemap/-/next-sitemap-3.1.42.tgz#f5c20f9a2cb66b75710bd7af4249041a47641af5"
integrity sha512-z/m440ZDCTxoE3FWbBWZLK66ZEh9e2R+j/Bm0d1Vo4PFkMi4yhWdIjWqhj//kyFyBvMYk3YWs8QQqVCCe15E6g==
dependencies:
"@corex/deepmerge" "^4.0.29"
minimist "^1.2.7"

next-themes@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/next-themes/-/next-themes-0.2.1.tgz#0c9f128e847979daf6c67f70b38e6b6567856e45"
Expand Down

0 comments on commit 671b80d

Please sign in to comment.