Gathering detailed insights and metrics for @auratiger/gatsby-plugin-advanced-sitemap-reworked
Gathering detailed insights and metrics for @auratiger/gatsby-plugin-advanced-sitemap-reworked
Gathering detailed insights and metrics for @auratiger/gatsby-plugin-advanced-sitemap-reworked
Gathering detailed insights and metrics for @auratiger/gatsby-plugin-advanced-sitemap-reworked
Advanced XML Sitemaps for Gatsby.js
npm install @auratiger/gatsby-plugin-advanced-sitemap-reworked
Typescript
Module System
Min. Node Version
JavaScript (84.61%)
XSLT (15.39%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
276 Commits
1 Branches
1 Contributors
Updated on Sep 12, 2022
Latest Version
2.1.0
Package Id
@auratiger/gatsby-plugin-advanced-sitemap-reworked@2.1.0
Unpacked Size
92.53 kB
Size
25.54 kB
File Count
55
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
The default Gatsby sitemap plugin generates a simple blob of raw XML for all your pages. This advanced sitemap plugin adds more power and configuration, generating a single or multiple sitemaps with full XSL templates to make them neatly organized and human + machine readable, as well linking image resources to encourage media indexing.
NOTE: This plugin only generates output in production
mode! To test, run: gatsby build && gatsby serve
npm install --save @auratiger/gatsby-plugin-advanced-sitemap-reworked
By default this plugin will generate a single sitemap of all pages on your site, without any configuration needed.
1// gatsby-config.js 2 3siteMetadata: { 4 siteUrl: `https://www.example.com`, 5}, 6plugins: [ 7 `@auratiger/gatsby-plugin-advanced-sitemap-reworked` 8]
If you want to generate advanced, individually organized sitemaps based on your data, you can do so by passing in a query and config. The example below uses Ghost, but this should work with any data source - including Pages, Markdown, Contentful, etc.
Example:
1// gatsby-config.js 2 3plugins: [ 4 { 5 resolve: `@auratiger/gatsby-plugin-advanced-sitemap-reworked`, 6 options: { 7 // 1 query for each data type 8 query: ` 9 { 10 posts: allSitePage(filter: {path: {regex: "//posts.*/"}}) { 11 edges { 12 node { 13 id 14 slug: path 15 url: path 16 pageContext 17 } 18 } 19 } 20 categories: allSitePage(filter: {path: {regex: "//categories.*/"}}) { 21 edges { 22 node { 23 id 24 slug: path 25 url: path 26 } 27 } 28 } 29 }`, 30 // The filepath and name to Index Sitemap. Defaults to '/sitemap.xml'. 31 output: "/custom-sitemap.xml", 32 mapping: { 33 // Each data type can be mapped to a predefined sitemap 34 // Routes can be grouped in one of: posts, tags, authors, pages, or a custom name 35 // The default sitemap - if none is passed - will be pages 36 posts: { 37 sitemap: `posts`, 38 // Add a query level prefix to slugs, Don't get confused with global path prefix from Gatsby 39 // This will add a prefix to this particular sitemap only 40 prefix: 'your-prefix/', 41 // Custom Serializer 42 serializer: (edges: any) => { 43 return edges.map(({ node }: any) => { 44 return { 45 node: { 46 id: node.id, 47 slug: node.slug, 48 url: node.url, 49 updated_at: node?.pageContext?.date, // updated_at || published_at || created_at 50 cover_image: node?.pageContext?.image, // cover_image || profile_image || feature_image; 51 }, 52 } 53 }) 54 }, 55 }, 56 categories: { 57 sitemap: `categories`, 58 serializer: (edges: any) => { 59 return edges.map(({ node }: any) => { 60 return { 61 node: { 62 id: node.id, 63 slug: node.slug, 64 url: node.url, 65 }, 66 } 67 }) 68 }, 69 }, 70 }, 71 exclude: [ 72 `/dev-404-page`, 73 `/404`, 74 `/404.html`, 75 `/offline-plugin-app-shell-fallback`, 76 `/my-excluded-page`, 77 /(\/)?hash-\S*/, // you can also pass valid RegExp to exclude internal tags for example 78 ], 79 createLinkInHead: true, // optional: create a link in the `<head>` of your site 80 addUncaughtPages: true, // optional: will fill up pages that are not caught by queries and mapping and list them under `sitemap-pages.xml` 81 additionalSitemaps: [ // optional: add additional sitemaps, which are e. g. generated somewhere else, but need to be indexed for this domain 82 { 83 name: `my-other-posts`, 84 url: `/blog/sitemap-posts.xml`, 85 }, 86 { 87 url: `https://example.com/sitemap.xml`, 88 }, 89 ], 90 } 91 } 92]
Example output of ☝️ this exact config 👉 https://gatsby.ghost.org/sitemap.xml
1yarn install
Build Plugin
1yarn build
Run Tests
1yarn test
object
receives: object[] - - Array of objects representing each page
Param | Type | Description |
---|---|---|
edges | object | this function receives the result of the executed queries |
Returns: object[] - - Array of objects containing the data needed to generate the sitemap urls
Return Object | Type | Description |
---|---|---|
id | string | page path |
url | string | page path |
slug | string | page path |
updated_at / published_at / created_at | string | Optional: string representing when last the page was updated |
cover_image / profile_image / feature_image | object | Optional: object representing a single image |
pageImages | object[] | Optional: Array containing multiple images to be linked for the page |
Image Object | Type | Description |
---|---|---|
path | string | image path |
caption | string | Optional: caption describing the image, similar to alt tags. |
No vulnerabilities found.
No security vulnerabilities found.