You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Solution (Added in 3rd June 2024)
I wrote some codes to solve this issue, maybe I can help others who searched from google.
in config.mjs or config.mts:
importfsfrom"fs";exportdefaultdefineConfig({sitemap: {hostname: "Your Domain",transformItems: (items)=>{// Reset last updated time of sitemap.xmlitems.forEach(item=>{consturl=item.url;// Read the file, replace the updated time from frontmatter with the time in git log// My blog path is "/docs", you can replace it to yours.constfile="docs/"+url+".md";try{constdata=fs.readFileSync(file,"utf-8");constgetUrl=data=>{constallLines=data.split("\n");for(leti=0;i<allLines.length;i++){constcurrentLine=allLines[i];// the statement i > 1 can prevent the program from suspending when reading at the first lineif(i>1&¤tLine==="---"){console.warn("There is no lastUpdated time in Frontmatter.");returnnull;}if(currentLine.indexOf("lastUpdated")>=0){returncurrentLine.replace("lastUpdated:","").trim();}}}constnewUpdatedTime=getUrl(data);// Only replace updated time when frontmatter value exists.if(newUpdatedTime){item.lastmod=newUpdatedTime;}}catch(err){console.error(err);returnfalse;}});returnfilteredItems;}},});
The text was updated successfully, but these errors were encountered:
Describe the bug
When generating sitemap, the lastmod attribute only uses the commit time in git log, but not lastUpdated value in frontmatter.
Reproduction
No need to add any templates.
Expected behavior
If the frontmatter contains lastUpdated key, generated sitemap should use the lastUpdated value, otherwise use the commit time in git log.
I remember the behavior was right in RC versions, not very sure.
System Info
Additional context
No response
Validations
Solution (Added in 3rd June 2024)
I wrote some codes to solve this issue, maybe I can help others who searched from google.
in config.mjs or config.mts:
The text was updated successfully, but these errors were encountered: