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
Fix go-sitemap-generator overriding GOMAXPROCs #141
Conversation
This upgrades the library to v2, which lets you specify that GOMAXPROCs should always be the max number of CPUs -- and then sets it to that. One side effect of this is that images are no longer listed in sitemaps. I'm somehow at a loss on how to build and append the images array we need, with the library's latest changes. Fixes #86
sitemap.go
Outdated
imgs = append(imgs, stm.URL{{"loc", i}, {"title", ""}}) | ||
} | ||
// FIXME: this is a pain. At a loss on how to do this | ||
u = append(u, []interface{}{[]interface{}{"image": imgs}}) |
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.
@robjloranger Could you help out with this whenever you have a chance?
changed to use stm.URL for imgs for readability fixed error in append statement reordered import statements
Thanks for taking a look, @robjloranger. Now when I try to get the sitemap on a blog that has posts which include images, I get this error:
|
ok I think I fixed it, I will test locally myself before pushing the commit |
<urlset xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
<loc>http://localhost:8080/rob/image-test</loc>
<lastmod>2019-08-01T23:35:29Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
<mobile:mobile/>
<image:image>
<image:loc>https://static1.srcdn.com/wordpress/wp-content/uploads/2019/07/Harley-Quinn-DC-Universe-Batman-and-Harley.jpg</image:loc>
<image:title/>
</image:image>
</url>
<url>
<loc>http://localhost:8080/rob/testing-this-thing</loc>
<lastmod>2019-07-01T22:03:09Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
<mobile:mobile/>
</url>
<url>
<loc>http://localhost:8080/rob/</loc>
<lastmod>2019-08-01T23:35:29Z</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
</urlset> How's this look? One post in my collection with an image results in this output with no error. |
Yep, looks good! |
Perfect, works for me as well! Merging now. |
This upgrades the
go-sitemap-generator
library to v2, which lets you specify that GOMAXPROCs should always be the max number of CPUs -- and then sets it to that.One side effect of this is that images are no longer listed in sitemaps. I'm somehow at a loss on how to build and append the images array we need, with the library's latest changes. Ideally we'd fix this -- any help would be much appreciated.
Fixes #86