-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db1e7c7
commit a2d53bc
Showing
5 changed files
with
45 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,37 @@ | ||
# fullstack-template | ||
# next-sitemap | ||
|
||
Fullstack project template | ||
Sitemap generator for next.js | ||
|
||
## Install | ||
|
||
```shell | ||
yarn add next-sitemap -D | ||
``` | ||
|
||
## Create config file | ||
|
||
`next-sitemap` requires a basic config file (`next-sitemap.js`) under your project root | ||
|
||
```js | ||
module.exports = { | ||
siteUrl: 'https://example.com' | ||
// other options | ||
} | ||
``` | ||
|
||
## Add next-sitemap as your postbuild script | ||
|
||
```json | ||
{ | ||
"build": "next build", | ||
"postbuild": "next-sitemap" | ||
} | ||
``` | ||
|
||
## `next-sitemap.js` Options | ||
|
||
| property | description | | ||
| --------------------- | ------------------------------------ | | ||
| siteUrl | Base url of your website | | ||
| changefreq (optional) | Change frequency. Default to `daily` | | ||
| priority (optional) | Priority. Default to `0.7` | |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
|
||
export const exportSitemap = (path: string, xml: string) => { | ||
fs.writeFileSync(path, xml) | ||
export const exportSitemap = (filePath: string, xml: string) => { | ||
const folder = path.dirname(filePath) | ||
if (!fs.existsSync(folder)) { | ||
fs.mkdirSync(folder) | ||
} | ||
|
||
fs.writeFileSync(filePath, xml) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters