Skip to content

Conversation

@araujogui
Copy link
Member

@araujogui araujogui commented Dec 15, 2025

Description

Create sitemap.xml generator

Validation

Related Issues

Fixes #255

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run node --run test and all tests passed.
  • I have check code formatting with node --run format & node --run lint.
  • I've covered new added functionality with unit tests if necessary.

@vercel
Copy link

vercel bot commented Dec 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
api-docs-tooling Ready Ready Preview Dec 15, 2025 1:09am

@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

❌ Patch coverage is 42.85714% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.35%. Comparing base (9ddf8f9) to head (8d07613).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/generators/sitemap/index.mjs 41.33% 44 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #520      +/-   ##
==========================================
- Coverage   79.58%   79.35%   -0.24%     
==========================================
  Files         120      121       +1     
  Lines       12056    12133      +77     
  Branches      841      842       +1     
==========================================
+ Hits         9595     9628      +33     
- Misses       2458     2502      +44     
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@avivkeller avivkeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I know this is a draft, but a few notes that I thought I might share.

These aren't blockers or concerns, just little notes.

Comment on lines +55 to +67
const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${allPages
.map(
page => ` <url>
<loc>${page.loc}</loc>
<lastmod>${page.lastmod}</lastmod>
<changefreq>${page.changefreq}</changefreq>
<priority>${page.priority}</priority>
</url>`
)
.join('\n')}
</urlset>`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is a draft, but I was wondering if:

  1. Does our HAST builder work?
  2. If not, can we use dedent for formatting?


return {
loc: url,
lastmod: new Date().toISOString().split('T')[0],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to create this Date for each entry?

Can't we initialize it once, and populate each lastmod from it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I was thinking of somehow getting the last modification date from the git repository

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that could also work, neat!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ovflowd What do you think?

Comment on lines +44 to +53
const mainPages = [
{
loc: new URL('/docs/latest/api/', BASE_URL).href,
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'daily',
priority: '1.0',
},
];

const allPages = [...mainPages, ...apiPages];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can optimize this by doing something like

Suggested change
const mainPages = [
{
loc: new URL('/docs/latest/api/', BASE_URL).href,
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'daily',
priority: '1.0',
},
];
const allPages = [...mainPages, ...apiPages];
apiPages.push({
loc: new URL('/docs/latest/api/', BASE_URL).href,
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'daily',
priority: '1.0',
})


const allPages = [...mainPages, ...apiPages];

const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make an actual file to store this template? And use handlebars or whatever we have already on doc-kit for replacement?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And use handlebars or whatever we have already on doc-kit for replacement?

(What we already have is .replace("__MY_VARIABLE__", MY_VALUE)

@ovflowd
Copy link
Member

ovflowd commented Dec 18, 2025

@araujogui is this ready for review?

@araujogui
Copy link
Member Author

@araujogui is this ready for review?

Not yet, I still need to implement: #520 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate sitemap.xml in the generator

4 participants