diff --git a/sitemap2/index.d.ts b/sitemap2/index.d.ts new file mode 100644 index 0000000000..75108ff603 --- /dev/null +++ b/sitemap2/index.d.ts @@ -0,0 +1,52 @@ +// Type definitions for sitemap2 1.0 +// Project: https://github.com/vlkosinov/sitemap2 +// Definitions by: Yuichi Shundo +// 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; +} diff --git a/sitemap2/sitemap2-tests.ts b/sitemap2/sitemap2-tests.ts new file mode 100644 index 0000000000..235cbb93a4 --- /dev/null +++ b/sitemap2/sitemap2-tests.ts @@ -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; diff --git a/sitemap2/tsconfig.json b/sitemap2/tsconfig.json new file mode 100644 index 0000000000..6fd2aba277 --- /dev/null +++ b/sitemap2/tsconfig.json @@ -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" + ] +} \ No newline at end of file diff --git a/sitemap2/tslint.json b/sitemap2/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/sitemap2/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file