mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
Merge pull request #4667 from cobbspur/sitemap
Provide absolute blog url in sitemap
This commit is contained in:
commit
8b7610bfb3
2 changed files with 5 additions and 18 deletions
|
@ -203,7 +203,8 @@ function checkSSL(req, res, next) {
|
||||||
// Handles requests to robots.txt and favicon.ico (and caches them)
|
// Handles requests to robots.txt and favicon.ico (and caches them)
|
||||||
function serveSharedFile(file, type, maxAge) {
|
function serveSharedFile(file, type, maxAge) {
|
||||||
var content,
|
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) {
|
return function serveSharedFile(req, res, next) {
|
||||||
if (req.url === '/' + file) {
|
if (req.url === '/' + file) {
|
||||||
|
@ -216,7 +217,7 @@ function serveSharedFile(file, type, maxAge) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
if (type === 'text/xsl' || type === 'text/plain') {
|
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 = {
|
content = {
|
||||||
headers: {
|
headers: {
|
||||||
|
|
|
@ -95,7 +95,7 @@
|
||||||
</table>
|
</table>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
<xsl:if test="count(sitemap:sitemapindex/sitemap:sitemap) < 1">
|
<xsl:if test="count(sitemap:sitemapindex/sitemap:sitemap) < 1">
|
||||||
<p class="desc"><a href="/sitemap.xml" class="back-link">← Back to index</a></p>
|
<p class="desc"><a href="{{blog-url}}/sitemap.xml" class="back-link">← Back to index</a></p>
|
||||||
<table id="sitemap" cellpadding="3">
|
<table id="sitemap" cellpadding="3">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -135,23 +135,9 @@
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p class="desc"><a href="/sitemap.xml" class="back-link">← Back to index</a></p>
|
<p class="desc"><a href="{{blog-url}}/sitemap.xml" class="back-link">← Back to index</a></p>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</div>
|
</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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue