Skip to content

Commit

Permalink
Update converter to compute canonical adress for training pages
Browse files Browse the repository at this point in the history
  • Loading branch information
javamind committed Dec 31, 2023
1 parent b8b03bf commit 2278733
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
11 changes: 8 additions & 3 deletions extension/convert-to-sitemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,24 @@ function extConvertToSitemap(options) {
}
var siteMetadata = JSON.parse(fs.readFileSync(pagesPath, model_1.FILE_ENCODING));
var xml = "";
function createUrlNode(metadata) {
function createUrlNode(file, metadata) {
if (!!metadata.priority && metadata.priority < 0) {
return '';
}
if (metadata.blog) {
return "<url>\n <loc>" + siteMetadata.url + "/blog/" + metadata.dir + "/" + metadata.filename + ".html</loc>\n <lastmod>" + moment(siteMetadata.revdate).format() + "</lastmod>\n <priority>0.51</priority>\n </url>";
if (file.path.lastIndexOf("blog/") > 0) {
return "<url>\n <loc>" + siteMetadata.url + "/blog/" + metadata.dir + "/" + metadata.filename + ".html</loc>\n <lastmod>" + moment(siteMetadata.revdate).format() + "</lastmod>\n <priority>0.51</priority>\n </url>";
}
if (file.path.lastIndexOf("training/") > 0) {
return "<url>\n <loc>" + siteMetadata.url + "/blog/" + metadata.dir + "/" + metadata.filename + ".html</loc>\n <lastmod>" + moment(siteMetadata.revdate).format() + "</lastmod>\n <priority>0.51</priority>\n </url>";
}
}
return "<url>\n <loc>" + siteMetadata.url + "/" + metadata.filename + ".html</loc>\n <lastmod>" + moment().format() + "</lastmod>\n <priority>" + (metadata.priority ? metadata.priority : 0.51) + "</priority>\n </url>";
}
var iterateOnStream = function (file, _, next) {
var data = JSON.parse(file.contents);
xml += data.length === 0 ? '' : data
.map(function (metadata) { return createUrlNode(metadata); })
.map(function (metadata) { return createUrlNode(file, metadata); })
.reduce(function (a, b) { return a + b; });
next(null, file);
};
Expand Down
23 changes: 16 additions & 7 deletions extension/convert-to-sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,25 @@ export function extConvertToSitemap(options: Options): Transform {

let xml = ``;

function createUrlNode(metadata) {
function createUrlNode(file, metadata) {
if (!!metadata.priority && metadata.priority < 0) {
return '';
}
if (metadata.blog) {
return `<url>
<loc>${siteMetadata.url}/blog/${metadata.dir}/${metadata.filename}.html</loc>
<lastmod>${moment(siteMetadata.revdate).format()}</lastmod>
<priority>0.51</priority>
</url>`;
if (file.path.lastIndexOf("blog/") > 0) {
return `<url>
<loc>${siteMetadata.url}/blog/${metadata.dir}/${metadata.filename}.html</loc>
<lastmod>${moment(siteMetadata.revdate).format()}</lastmod>
<priority>0.51</priority>
</url>`;
}
if (file.path.lastIndexOf("training/") > 0) {
return `<url>
<loc>${siteMetadata.url}/blog/${metadata.dir}/${metadata.filename}.html</loc>
<lastmod>${moment(siteMetadata.revdate).format()}</lastmod>
<priority>0.51</priority>
</url>`;
}
}
return `<url>
<loc>${siteMetadata.url}/${metadata.filename}.html</loc>
Expand All @@ -45,7 +54,7 @@ export function extConvertToSitemap(options: Options): Transform {
const iterateOnStream = function (file, _, next) {
const data = JSON.parse(file.contents);
xml += data.length === 0 ? '' : data
.map(metadata => createUrlNode(metadata))
.map(metadata => createUrlNode(file, metadata))
.reduce((a, b) => a + b);
next(null, file)
};
Expand Down
3 changes: 2 additions & 1 deletion src/blog/2018/test2.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
:category: Agilité
:teaser: Test
:imgteaser: ../../img/blog/2015/formes_leadership_00.jpg
:icons: font

Test

[source, java, subs="specialchars"]
----
@RequestMapping("/api/hello")
@RequestMapping("/api/hello") // <1>
class CallForPaperServiceTests {
/**
* Java comment
Expand Down

0 comments on commit 2278733

Please sign in to comment.