add sitemap2 (#14972)

This commit is contained in:
Yuichi Shundo 2017-03-10 15:08:19 +09:00 committed by Mohamed Hegazy
parent 123ff1c182
commit 2f73151f60
4 changed files with 126 additions and 0 deletions

52
sitemap2/index.d.ts vendored Normal file
View File

@ -0,0 +1,52 @@
// Type definitions for sitemap2 1.0
// Project: https://github.com/vlkosinov/sitemap2
// Definitions by: Yuichi Shundo <https://github.com/shundy>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare var sitemap2: Sitemap;
export = sitemap2;
declare interface Sitemap {
new (conf?: SitemapConfig): Sitemap;
addUrl(urlData: UrlData | UrlData[] | string | string[]): this
addSitemap(sm: Sitemap): this;
toXML(): SitemapXml[];
hostName: string;
fileName: string;
limit: number;
urls: string[];
childrens: Sitemap[];
}
declare interface SitemapConfig {
hostName?: string;
fileName?: string;
limit?: number;
cacheTime?: number;
xslUrl?: string;
urls?: string[];
childrens?: Sitemap[];
}
declare interface UrlData {
url: string;
chengefreq?: string;
priority?: number | string;
lastmod?: Date;
lastmodWithTime?: boolean;
lastmodInISO?: boolean;
video?: {
title: string;
description: string;
thumbnail_loc: string;
content_loc: string;
}
}
declare interface SitemapXml {
fileName: string;
xml: string;
}

View File

@ -0,0 +1,51 @@
import Sitemap = require('sitemap2');
let sitemap = new Sitemap({
hostName: ('https://example.com/'),
fileName: 'sitemap.xml',
limit: 50000,
cacheTime: 1000,
});
sitemap.addUrl('https://example.com/');
sitemap.addUrl(['https://example.com/']);
sitemap.addUrl({
url: 'https://example.com/',
chengefreq: 'chengefreq',
priority: 0.6,
lastmod: new Date(),
lastmodWithTime: true,
lastmodInISO: false,
video: {
title: 'title',
description: 'description',
content_loc: 'content_loc',
thumbnail_loc: 'thumbnail_loc'
},
});
sitemap.addUrl([
{
url: 'https://example.com/',
chengefreq: 'chengefreq',
priority: 0.6,
lastmod: new Date(),
lastmodWithTime: true,
lastmodInISO: false,
video: {
title: 'title',
description: 'description',
content_loc: 'content_loc',
thumbnail_loc: 'thumbnail_loc'
},
},
{
url: 'http://example.com/'
}
]);
let sitemap2 = new Sitemap();
sitemap.addSitemap(sitemap2);
const xmlList = sitemap.toXML();
var str = xmlList[0].fileName;
var str = xmlList[0].xml;

22
sitemap2/tsconfig.json Normal file
View File

@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"sitemap2-tests.ts"
]
}

1
sitemap2/tslint.json Normal file
View File

@ -0,0 +1 @@
{ "extends": "../tslint.json" }