-
-
Notifications
You must be signed in to change notification settings - Fork 2
Add types #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add types #1
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Minimum TypeScript Version: 3.5 | ||
|
||
import {Root} from 'xast' | ||
|
||
/** | ||
* Entries represent a single URL and describe them with metadata. | ||
*/ | ||
export interface Entry { | ||
/** | ||
* Full URL. | ||
* | ||
* @see https://www.sitemaps.org/protocol.html#locdef | ||
* | ||
* @example 'https://example.org/' | ||
*/ | ||
url: string | ||
|
||
/** | ||
* Value indicating when the page last changed. | ||
*/ | ||
modified?: Date | string | number | ||
|
||
/** | ||
* BCP 47 tag indicating the language of the page. | ||
* | ||
* @see https://github.com/wooorm/bcp-47 | ||
* | ||
* @example 'en-GB' | ||
*/ | ||
lang?: string | ||
|
||
/** | ||
* Translations of the page, where each key is a BCP 47 tag and each value an entry. | ||
* | ||
* Alternate resources inherit fields from the entry they are described in. | ||
* | ||
* @see https://github.com/wooorm/bcp-47 | ||
*/ | ||
alternate?: Record<string, string | Omit<Entry, 'lang' | 'alternate'>> | ||
} | ||
|
||
/** | ||
* Build a sitemap. | ||
* | ||
* @param data URLs to build a sitemap for. | ||
*/ | ||
export function sitemap(data: Array<string | Entry>): Root |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {sitemap} from 'xast-util-sitemap' | ||
|
||
sitemap() // $ExpectError | ||
sitemap([ | ||
'https://example.com', | ||
{url: 'https://example.com'}, | ||
{url: 'https://example.com', modified: new Date()}, | ||
{url: 'https://example.com', modified: Date.now()}, | ||
{url: 'https://example.com', modified: '01-02-2021'}, | ||
{url: 'https://example.com', lang: 'en-GB'}, | ||
{ | ||
url: 'https://example.com', | ||
lang: 'en-GB', | ||
alternate: {'de-AT': 'https://example.at'} | ||
}, | ||
{ | ||
url: 'https://example.com', | ||
lang: 'en-GB', | ||
alternate: {'de-AT': {url: 'https://example.at', modified: Date.now()}} | ||
} | ||
]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "es2015", | ||
"lib": ["es2015"], | ||
"moduleResolution": "node", | ||
"strict": true, | ||
"noEmit": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"xast-util-sitemap": ["."] | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
{ | ||
"extends": "dtslint/dtslint.json", | ||
"rules": { | ||
"no-redundant-jsdoc": false, | ||
"no-redundant-jsdoc-2": true, | ||
"semicolon": false, | ||
"whitespace": false | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.