Registry / http-networking / gatsby-source-build-date

gatsby-source-build-date

JSON →
library1.0.1jsnpmunverified

The `gatsby-source-build-date` plugin, currently at version 1.0.1, provides a straightforward mechanism for integrating the site's compilation timestamp into Gatsby's internal GraphQL API. This enables developers to easily display a "Last Updated" or "Last Built" date in any component or page without manual updates. Unlike its predecessor, `gatsby-plugin-build-date`, this hard fork leverages Node.js's native `Intl.DateTimeFormat` for date internationalization and formatting, eliminating the dependency on third-party date libraries. This approach offers robust localization capabilities, allowing developers to specify `locales` and `options` directly in their `gatsby-config.js` for precise date string representation. The plugin makes the build date available as a `buildDate` node in the GraphQL schema, which can then be queried and formatted using Gatsby's standard GraphQL `formatString` arguments for `Date` types. It is specifically designed to reflect the timestamp of the entire site build process, not individual file modification times. As a Gatsby plugin, its release cadence is generally tied to the stability of the core Gatsby ecosystem, with updates typically addressing compatibility or minor enhancements rather than frequent breaking changes, especially given its reliance on a core Node.js API.

http-networking
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Gatsby plugins are configured by their string name in `gatsby-config.js` for default behavior, not directly imported into component files.

// In gatsby-config.js module.exports = { plugins: [ `gatsby-source-build-date` ], };

To specify localization or formatting, the plugin must be configured as an object in `gatsby-config.js`.

// In gatsby-config.js module.exports = { plugins: [ { resolve: `gatsby-source-build-date`, options: { locales: "fr-FR", options: { weekday: "long", year: "numeric", month: "long", day: "numeric" } } } ], };

The build date is exposed as the `buildDate` field in Gatsby's GraphQL API, accessible via `useStaticQuery` or page queries in components.

query MySiteBuildDate { buildDate { date(formatString: "MMMM DD, YYYY HH:mm:ss z") } }

Demonstrates how to configure `gatsby-source-build-date` in `gatsby-config.js` with custom options and how to query the build date via GraphQL.

// gatsby-config.ts (or .js) import type { GatsbyConfig } from 'gatsby'; const config: GatsbyConfig = { plugins: [ { resolve: `gatsby-source-build-date`, options: { locales: "en-US", // or "fr-FR", etc. options: { year: "numeric", month: "long", day: "numeric", hour: "numeric", minute: "numeric", second: "numeric", timeZoneName: "short", }, }, }, ], }; export default config; // Example GraphQL query (run in Gatsby's GraphiQL IDE or a page query) // After configuring, restart your Gatsby development server. // Then navigate to http://localhost:8000/___graphql and run this query: /* query SiteBuildDate { buildDate { date # The date field is a Date object, allowing further formatting with formatString formattedDate: date(formatString: "YYYY-MM-DD HH:mm:ss Z") } } */
Debug
Known footguns
gotchaNode.js versions 12.x (e.g., v12.22) may ignore locale strings and formatting options provided to the plugin, resulting in dates being displayed in default English format regardless of configuration.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
5 hits · last 30 days
ahrefsbot
4
script
1
Resources