2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

Provide absolute blog url in sitemap

No issue

- Adds {{blog-url}} to sitemap.xsl
- Replaces all occurences of {{blog-url}} with absolute bkog url
This commit is contained in:
cobbspur 2014-12-17 14:55:27 +00:00
parent e0f65b899e
commit cbcda2faf8
2 changed files with 5 additions and 18 deletions

View file

@ -203,7 +203,8 @@ function checkSSL(req, res, next) {
// Handles requests to robots.txt and favicon.ico (and caches them)
function serveSharedFile(file, type, maxAge) {
var content,
filePath = path.join(config.paths.corePath, 'shared', file);
filePath = path.join(config.paths.corePath, 'shared', file),
re = /(\{\{blog-url\}\})/g;
return function serveSharedFile(req, res, next) {
if (req.url === '/' + file) {
@ -216,7 +217,7 @@ function serveSharedFile(file, type, maxAge) {
return next(err);
}
if (type === 'text/xsl' || type === 'text/plain') {
buf = buf.toString().replace('{{blog-url}}', config.url.replace(/\/$/, ''));
buf = buf.toString().replace(re, config.url.replace(/\/$/, ''));
}
content = {
headers: {

View file

@ -95,7 +95,7 @@
</table>
</xsl:if>
<xsl:if test="count(sitemap:sitemapindex/sitemap:sitemap) &lt; 1">
<p class="desc"><a href="/sitemap.xml" class="back-link">&#8592; Back to index</a></p>
<p class="desc"><a href="{{blog-url}}/sitemap.xml" class="back-link">&#8592; Back to index</a></p>
<table id="sitemap" cellpadding="3">
<thead>
<tr>
@ -135,23 +135,9 @@
</xsl:for-each>
</tbody>
</table>
<p class="desc"><a href="/sitemap.xml" class="back-link">&#8592; Back to index</a></p>
<p class="desc"><a href="{{blog-url}}/sitemap.xml" class="back-link">&#8592; Back to index</a></p>
</xsl:if>
</div>
<script type="text/javascript">
<![CDATA[
window.onload = function() {
var sitemapIndex = window.location.href.replace(/sitemap-.*\.xml$/, 'sitemap.xml'),
links = document.querySelectorAll('.back-link'),
i;
if (links.length > 0) {
for (i = 0; i < links.length; ++i) {
links[i].href = sitemapIndex;
}
}
};
]]>
</script>
</body>
</html>