Skip to content

fix(sitemap): don't drop lastmod for an epoch (0) timestamp - #12212

Merged
slorber merged 1 commit into
facebook:mainfrom
durvesh1992:fix/sitemap-lastmod-epoch
Jul 9, 2026
Merged

fix(sitemap): don't drop lastmod for an epoch (0) timestamp#12212
slorber merged 1 commit into
facebook:mainfrom
durvesh1992:fix/sitemap-lastmod-epoch

Conversation

@durvesh1992

Copy link
Copy Markdown
Contributor

Motivation

createSitemapItem decides a route's <lastmod> from route.metadata.lastUpdatedAt (a numeric timestamp, e.g. derived from front matter last_update: {date: ...}). Two checks use truthiness on that number:

// getRouteLastUpdatedAt
if (route.metadata?.lastUpdatedAt) { ... }            // 0 is falsy → skipped
// getRouteLastmod
return lastUpdatedAt ? formatLastmod(...) : null;      // 0 → null

So a legitimate timestamp of 0 (1970-01-01T00:00:00Z) is treated as "no value" and the <lastmod> is silently omitted. The adjacent === null early-return already shows the intent to distinguish absent from present — the truthiness checks defeat that for 0.

Fix

Use != null in both places so 0 is preserved (while still treating null/undefined as absent).

Test plan

pnpm vitest run packages/docusaurus-plugin-sitemap

Added a regression test (lastUpdatedAt: 0lastmod: '1970-01-01') that fails before this change and passes after. Full sitemap package: 53 tests pass.

getRouteLastUpdatedAt/getRouteLastmod used truthiness checks on the
numeric lastUpdatedAt, so a legitimate timestamp of 0 (1970-01-01, e.g.
from front matter last_update: {date: 1970-01-01}) was treated as 'no
value' and the <lastmod> entry was silently omitted. The adjacent
=== null guard already shows the intent to distinguish absent from
present. Use != null so 0 is preserved.

Adds a regression test (fails before / passes after).
@meta-cla meta-cla Bot added the CLA Signed Signed Facebook CLA label Jun 29, 2026
@netlify

netlify Bot commented Jun 29, 2026

Copy link
Copy Markdown

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 15ac020
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6a42f75471e7ac000835085b
😎 Deploy Preview https://deploy-preview-12212--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@slorber slorber added the pr: bug fix This PR fixes a bug in a past release. label Jul 9, 2026
@slorber

slorber commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Hmmm, ok to merge this but really wonder what the use case for having a lastmod with epoch 0 ?

Is this only theoretical and for correctness, or do you plan to use this in practice?

@slorber slorber added the to backport This PR is planned to be backported to a stable version of Docusaurus label Jul 9, 2026
@slorber
slorber merged commit be38778 into facebook:main Jul 9, 2026
38 of 39 checks passed
yamz8 pushed a commit to forgente/docs that referenced this pull request Jul 27, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [@docusaurus/core](https://github.com/facebook/docusaurus) ([source](https://github.com/facebook/docusaurus/tree/HEAD/packages/docusaurus)) | [`3.10.1` → `3.10.2`](https://renovatebot.com/diffs/npm/@docusaurus%2fcore/3.10.1/3.10.2) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@docusaurus%2fcore/3.10.2?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@docusaurus%2fcore/3.10.1/3.10.2?slim=true) |
| [@docusaurus/faster](https://github.com/facebook/docusaurus) ([source](https://github.com/facebook/docusaurus/tree/HEAD/packages/docusaurus-faster)) | [`3.10.1` → `3.10.2`](https://renovatebot.com/diffs/npm/@docusaurus%2ffaster/3.10.1/3.10.2) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@docusaurus%2ffaster/3.10.2?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@docusaurus%2ffaster/3.10.1/3.10.2?slim=true) |
| [@docusaurus/module-type-aliases](https://github.com/facebook/docusaurus) ([source](https://github.com/facebook/docusaurus/tree/HEAD/packages/docusaurus-module-type-aliases)) | [`3.10.1` → `3.10.2`](https://renovatebot.com/diffs/npm/@docusaurus%2fmodule-type-aliases/3.10.1/3.10.2) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@docusaurus%2fmodule-type-aliases/3.10.2?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@docusaurus%2fmodule-type-aliases/3.10.1/3.10.2?slim=true) |
| [@docusaurus/plugin-content-docs](https://github.com/facebook/docusaurus) ([source](https://github.com/facebook/docusaurus/tree/HEAD/packages/docusaurus-plugin-content-docs)) | [`3.10.1` → `3.10.2`](https://renovatebot.com/diffs/npm/@docusaurus%2fplugin-content-docs/3.10.1/3.10.2) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@docusaurus%2fplugin-content-docs/3.10.2?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@docusaurus%2fplugin-content-docs/3.10.1/3.10.2?slim=true) |
| [@docusaurus/preset-classic](https://github.com/facebook/docusaurus) ([source](https://github.com/facebook/docusaurus/tree/HEAD/packages/docusaurus-preset-classic)) | [`3.10.1` → `3.10.2`](https://renovatebot.com/diffs/npm/@docusaurus%2fpreset-classic/3.10.1/3.10.2) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@docusaurus%2fpreset-classic/3.10.2?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@docusaurus%2fpreset-classic/3.10.1/3.10.2?slim=true) |

---

### Release Notes

<details>
<summary>facebook/docusaurus (@&#8203;docusaurus/core)</summary>

### [`v3.10.2`](https://github.com/facebook/docusaurus/blob/HEAD/CHANGELOG.md#3102-2026-07-10)

[Compare Source](facebook/docusaurus@v3.10.1...v3.10.2)

Backport and cherry-pick commits from main for v3.10.2 patch release:

- [fix(bundler): do not import `@swc/html`, fix StackBlitz playground #&#8203;12055](facebook/docusaurus#12055)
- [fix(core): use locale url in site config #&#8203;12054](facebook/docusaurus#12054)
- [fix(theme-classic): remove redundant sidebar label titles #&#8203;11966](facebook/docusaurus#11966)
- [fix(mdx-loader): avoid transforming dotted directory links into asset… #&#8203;11944](facebook/docusaurus#11944)
- [fix(dev-server): for HTTPS, support non-RSA TLS certs #&#8203;12065](facebook/docusaurus#12065)
- [fix(utils): fix `extractLeadingEmoji()` edge cases #&#8203;12100](facebook/docusaurus#12100)
- [fix(gtag.js, faster): Fix StackBlitz, vendor `@types/gtag.js`, upgrade `@swc/html` #&#8203;12080](facebook/docusaurus#12080)
- [fix(create-docusaurus): init template README should use npm commands by default #&#8203;12138](facebook/docusaurus#12138)
- [fix(cli): `docusaurus serve` should pass `--host` to `server.listen()` #&#8203;12127](facebook/docusaurus#12127)
- [fix(core): bump detect-port to v2.1, fix pnpm `trustPolicy` downgrade issue #&#8203;12012](facebook/docusaurus#12012)
- [fix(i18n): complete Spanish translations for theme-common and theme-l… #&#8203;12180](facebook/docusaurus#12180)
- [chore(deps): migrate to `@11ty/gray-matter` #&#8203;12181](facebook/docusaurus#12181)
- [fix(core): fix BaseUrlIssueBanner little security issue #&#8203;12260](facebook/docusaurus#12260)
- [fix(core): accept boolean attributes in headTags config validation #&#8203;12238](facebook/docusaurus#12238)
- [fix(sitemap): don't drop lastmod for an epoch (0) timestamp #&#8203;12212](facebook/docusaurus#12212)
- [fix(utils): preserve author names containing commas in git log parsing #&#8203;12069](facebook/docusaurus#12069)

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xOTEuMiIsInVwZGF0ZWRJblZlciI6IjQzLjE5MS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/docs/pulls/466
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release. to backport This PR is planned to be backported to a stable version of Docusaurus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants