-
Notifications
You must be signed in to change notification settings - Fork 21
feat: create sitemap generator #520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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.
| 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>`; |
There was a problem hiding this comment.
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:
- Does our HAST builder work?
- If not, can we use
dedentfor formatting?
|
|
||
| return { | ||
| loc: url, | ||
| lastmod: new Date().toISOString().split('T')[0], |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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?
| 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]; |
There was a problem hiding this comment.
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
| 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"?> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
|
@araujogui is this ready for review? |
Not yet, I still need to implement: #520 (comment) |
Description
Create sitemap.xml generator
Validation
Related Issues
Fixes #255
Check List
node --run testand all tests passed.node --run format&node --run lint.