remix-sitemap
Advanced tools
Comparing version 1.3.2 to 1.3.3
@@ -1,2 +0,2 @@ | ||
import { Config } from './types'; | ||
import type { Config } from './types'; | ||
export declare const getConfig: (config: Config) => { | ||
@@ -3,0 +3,0 @@ autoLastmod: boolean; |
@@ -54,3 +54,3 @@ type ChangeFreq = 'never' | 'yearly' | 'monthly' | 'weekly' | 'daily' | 'hourly' | 'always'; | ||
playerLoc: string; | ||
restriction: { | ||
restriction?: { | ||
relationship: 'allow' | 'deny'; | ||
@@ -66,3 +66,2 @@ countries: string[]; | ||
tags?: string[]; | ||
galleryTitle?: string; | ||
requiresSubscription?: boolean; | ||
@@ -77,3 +76,6 @@ price?: { | ||
}; | ||
platform?: string; | ||
platform?: { | ||
relationship: 'allow' | 'deny'; | ||
content: string[]; | ||
}; | ||
live?: boolean; | ||
@@ -80,0 +82,0 @@ } |
@@ -13,2 +13,2 @@ import type { EntryContext } from '@remix-run/server-runtime'; | ||
}; | ||
export declare function getEntry(params: GetEntryParams): Promise<string>; | ||
export declare function getEntry(params: GetEntryParams): Promise<any>; |
@@ -7,3 +7,3 @@ "use strict"; | ||
const validations_1 = require("./utils/validations"); | ||
const xml_1 = require("./utils/xml"); | ||
const sitemap_1 = require("./builders/sitemap"); | ||
async function sitemapResponse(config, request, context) { | ||
@@ -62,4 +62,4 @@ const sitemap = await getSitemap({ | ||
if (entries) | ||
return entries === null || entries === void 0 ? void 0 : entries.map(entry => (0, xml_1.getEntryXml)({ config, entry })).join(''); | ||
return (0, xml_1.getEntryXml)({ | ||
return entries === null || entries === void 0 ? void 0 : entries.map(entry => (0, sitemap_1.buildSitemapUrl)({ config, entry })).join(''); | ||
return (0, sitemap_1.buildSitemapUrl)({ | ||
config, | ||
@@ -66,0 +66,0 @@ entry: { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const config_1 = require("../../lib/config"); | ||
const xml_1 = require("../xml"); | ||
describe('xml', () => { | ||
const config = (0, config_1.getConfig)({ | ||
siteUrl: 'https://example.com', | ||
autoLastmod: false | ||
}); | ||
it('snapshot test for google images', () => { | ||
const entry = (0, xml_1.getEntryXml)({ | ||
config, | ||
entry: { | ||
loc: '/test', | ||
images: [ | ||
{ | ||
loc: 'https://example.com/image.jpg' | ||
} | ||
] | ||
} | ||
describe('xml util', () => { | ||
describe('getBooleanValue', () => { | ||
it('should return yes for true', () => { | ||
expect((0, xml_1.getBooleanValue)(true)).toBe('yes'); | ||
}); | ||
expect(entry).toMatchInlineSnapshot(` | ||
"<url><loc>https://example.com/test</loc><changefreq>daily</changefreq><priority>0.7</priority><image:image><image:loc>https://example.com/image.jpg</image:loc></image:image></url>" | ||
`); | ||
}); | ||
it('snapshot test for google news', () => { | ||
const entry = (0, xml_1.getEntryXml)({ | ||
config, | ||
entry: { | ||
loc: '/test', | ||
news: [ | ||
{ | ||
date: '2021-01-01', | ||
publication: { | ||
name: 'Example', | ||
language: 'en' | ||
}, | ||
title: 'Example title' | ||
} | ||
] | ||
} | ||
it('should return no for false', () => { | ||
expect((0, xml_1.getBooleanValue)(false)).toBe('no'); | ||
}); | ||
expect(entry).toMatchInlineSnapshot(` | ||
"<url><loc>https://example.com/test</loc><changefreq>daily</changefreq><priority>0.7</priority><news:news><news:publication><news:name>Example</news:name><news:language>en</news:language></news:publication><news:publication_date>2021-01-01</news:publication_date><news:title>Example title</news:title></news:news></url>" | ||
`); | ||
}); | ||
it('snapshot test for google video', () => { | ||
const entry = (0, xml_1.getEntryXml)({ | ||
config, | ||
entry: { | ||
loc: '/test', | ||
videos: [ | ||
{ | ||
contentLoc: 'https://example.com/video.mp4', | ||
title: 'Example video', | ||
description: 'Example video description', | ||
thumbnailLoc: 'https://example.com/thumbnail.jpg', | ||
playerLoc: 'https://example.com/player', | ||
duration: 60, | ||
expirationDate: '2021-01-01', | ||
rating: 4.5, | ||
viewCount: 100, | ||
publicationDate: '2021-01-01', | ||
familyFriendly: true, | ||
restriction: { | ||
relationship: 'allow', | ||
countries: ['US', 'CA'] | ||
}, | ||
price: { | ||
currency: 'USD', | ||
value: 1.99 | ||
}, | ||
galleryTitle: 'Example gallery', | ||
tags: ['example', 'video'], | ||
requiresSubscription: true, | ||
uploader: { | ||
name: 'Example', | ||
info: 'https://example.com/uploader' | ||
}, | ||
platform: 'web', | ||
live: true | ||
} | ||
] | ||
} | ||
describe('getOptionalValue', () => { | ||
it('should return undefined for undefined', () => { | ||
expect((0, xml_1.getOptionalValue)(undefined, {})).toBeUndefined(); | ||
}); | ||
expect(entry).toMatchInlineSnapshot(` | ||
"<url><loc>https://example.com/test</loc><changefreq>daily</changefreq><priority>0.7</priority><video:video><video:thumbnail_loc>https://example.com/thumbnail.jpg</video:thumbnail_loc><video:title>Example video</video:title><video:description>Example video description</video:description><video:content_loc>https://example.com/video.mp4</video:content_loc><video:player_loc>https://example.com/player</video:player_loc><video:duration>60</video:duration><video:expiration_date>2021-01-01</video:expiration_date><video:rating>4.5</video:rating><video:view_count>100</video:view_count><video:publication_date>2021-01-01</video:publication_date><video:family_friendly>yes</video:family_friendly><video:restriction relationship=\\"allow\\">US CA</video:restriction><video:price currency=\\"USD\\">1.99</video:price><video:requires_subscription>yes</video:requires_subscription><video:uploader info=\\"https://example.com/uploader\\">Example</video:uploader><video:live>yes</video:live><video:tag>example</video:tag><video:tag>video</video:tag></video:video></url>" | ||
`); | ||
}); | ||
it('snapshot test for alternateRefs', () => { | ||
const entryUsingAbsolute = (0, xml_1.getEntryXml)({ | ||
config, | ||
entry: { | ||
loc: '/test', | ||
alternateRefs: [ | ||
{ | ||
href: 'https://example.com/en/test', | ||
absolute: true, | ||
hreflang: 'en' | ||
} | ||
] | ||
} | ||
it('should return undefined for null', () => { | ||
expect((0, xml_1.getOptionalValue)(null, {})).toBeUndefined(); | ||
}); | ||
expect(entryUsingAbsolute).toMatchInlineSnapshot(` | ||
"<url><loc>https://example.com/test</loc><changefreq>daily</changefreq><priority>0.7</priority><xhtml:link rel=\\"alternate\\" hreflang=\\"en\\" href=\\"https://example.com/en/test\\"/></url>" | ||
`); | ||
const entryUsingRelative = (0, xml_1.getEntryXml)({ | ||
config, | ||
entry: { | ||
loc: '/test', | ||
alternateRefs: [ | ||
{ | ||
href: 'https://example.com/en', | ||
hreflang: 'en' | ||
} | ||
] | ||
} | ||
it('should return undefined for empty string', () => { | ||
expect((0, xml_1.getOptionalValue)('', {})).toBeUndefined(); | ||
}); | ||
expect(entryUsingRelative).toMatchInlineSnapshot(` | ||
"<url><loc>https://example.com/test</loc><changefreq>daily</changefreq><priority>0.7</priority><xhtml:link rel=\\"alternate\\" hreflang=\\"en\\" href=\\"https://example.com/en/test\\"/></url>" | ||
`); | ||
it('should return returnValue for non-empty string', () => { | ||
expect((0, xml_1.getOptionalValue)('value', { hello: 'world' })).toStrictEqual({ | ||
hello: 'world' | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -1,3 +0,3 @@ | ||
import { EntryContext } from '@remix-run/server-runtime'; | ||
import { RemixSitemapConfig } from '../lib/types'; | ||
import type { EntryContext } from '@remix-run/server-runtime'; | ||
import type { RemixSitemapConfig } from '../lib/types'; | ||
export declare function getRouteData(route: string, context: EntryContext): { | ||
@@ -4,0 +4,0 @@ manifest: import("@remix-run/server-runtime/dist/routes").EntryRoute; |
@@ -5,3 +5,3 @@ "use strict"; | ||
const data_1 = require("./data"); | ||
const xml_1 = require("./xml"); | ||
const sitemap_1 = require("../builders/sitemap"); | ||
const validations_1 = require("./validations"); | ||
@@ -17,3 +17,3 @@ function getOptionalSegmentEntries(params) { | ||
if (!entries) { | ||
return (0, xml_1.getEntryXml)({ | ||
return (0, sitemap_1.buildSitemapUrl)({ | ||
config, | ||
@@ -26,3 +26,3 @@ entry: { | ||
else { | ||
return entries === null || entries === void 0 ? void 0 : entries.map(entry => (0, xml_1.getEntryXml)({ | ||
return entries === null || entries === void 0 ? void 0 : entries.map(entry => (0, sitemap_1.buildSitemapUrl)({ | ||
config, | ||
@@ -39,3 +39,3 @@ entry: { | ||
if (fullPath && !(0, validations_1.isDynamicPath)(fullPath)) { | ||
finalEntry.push((0, xml_1.getEntryXml)({ | ||
finalEntry.push((0, sitemap_1.buildSitemapUrl)({ | ||
config, | ||
@@ -48,3 +48,3 @@ entry: { | ||
entries === null || entries === void 0 ? void 0 : entries.forEach(entry => { | ||
finalEntry.push((0, xml_1.getEntryXml)({ | ||
finalEntry.push((0, sitemap_1.buildSitemapUrl)({ | ||
config, | ||
@@ -51,0 +51,0 @@ entry: { |
@@ -1,3 +0,3 @@ | ||
import { EntryContext } from '@remix-run/server-runtime'; | ||
import { RemixSitemapConfig } from '../lib/types'; | ||
import type { EntryContext } from '@remix-run/server-runtime'; | ||
import type { RemixSitemapConfig } from '../lib/types'; | ||
export declare function isSitemapUrl(config: RemixSitemapConfig, request: Request): boolean; | ||
@@ -4,0 +4,0 @@ export declare const isDynamicPath: (path?: string) => boolean | undefined; |
@@ -1,331 +0,2 @@ | ||
import type { SitemapEntry, AlternateRef, News, Image, Video, RemixSitemapConfig } from '../lib/types'; | ||
export declare const getAlternateRef: (alternateRefs: AlternateRef) => { | ||
'xhtml:link': { | ||
_attr: { | ||
rel: string; | ||
hreflang: string; | ||
href: string; | ||
}; | ||
}; | ||
}; | ||
export declare const getImage: (image: Image) => { | ||
'image:image': { | ||
'image:loc': string; | ||
}[]; | ||
}; | ||
export declare const getNews: (news: News) => { | ||
'news:news': ({ | ||
'news:publication': ({ | ||
'news:name': string; | ||
'news:language'?: undefined; | ||
} | { | ||
'news:language': string; | ||
'news:name'?: undefined; | ||
})[]; | ||
'news:publication_date'?: undefined; | ||
'news:title'?: undefined; | ||
} | { | ||
'news:publication_date': string | Date; | ||
'news:publication'?: undefined; | ||
'news:title'?: undefined; | ||
} | { | ||
'news:title': string; | ||
'news:publication'?: undefined; | ||
'news:publication_date'?: undefined; | ||
})[]; | ||
}; | ||
export declare const getVideo: (video: Video) => { | ||
'video:video': ({ | ||
'video:tag': string; | ||
} | { | ||
'video:thumbnail_loc': string; | ||
'video:title'?: undefined; | ||
'video:description'?: undefined; | ||
'video:content_loc'?: undefined; | ||
'video:player_loc'?: undefined; | ||
'video:duration'?: undefined; | ||
'video:expiration_date'?: undefined; | ||
'video:rating'?: undefined; | ||
'video:view_count'?: undefined; | ||
'video:publication_date'?: undefined; | ||
'video:family_friendly'?: undefined; | ||
'video:restriction'?: undefined; | ||
'video:price'?: undefined; | ||
'video:requires_subscription'?: undefined; | ||
'video:uploader'?: undefined; | ||
'video:live'?: undefined; | ||
} | { | ||
'video:title': string; | ||
'video:thumbnail_loc'?: undefined; | ||
'video:description'?: undefined; | ||
'video:content_loc'?: undefined; | ||
'video:player_loc'?: undefined; | ||
'video:duration'?: undefined; | ||
'video:expiration_date'?: undefined; | ||
'video:rating'?: undefined; | ||
'video:view_count'?: undefined; | ||
'video:publication_date'?: undefined; | ||
'video:family_friendly'?: undefined; | ||
'video:restriction'?: undefined; | ||
'video:price'?: undefined; | ||
'video:requires_subscription'?: undefined; | ||
'video:uploader'?: undefined; | ||
'video:live'?: undefined; | ||
} | { | ||
'video:description': string; | ||
'video:thumbnail_loc'?: undefined; | ||
'video:title'?: undefined; | ||
'video:content_loc'?: undefined; | ||
'video:player_loc'?: undefined; | ||
'video:duration'?: undefined; | ||
'video:expiration_date'?: undefined; | ||
'video:rating'?: undefined; | ||
'video:view_count'?: undefined; | ||
'video:publication_date'?: undefined; | ||
'video:family_friendly'?: undefined; | ||
'video:restriction'?: undefined; | ||
'video:price'?: undefined; | ||
'video:requires_subscription'?: undefined; | ||
'video:uploader'?: undefined; | ||
'video:live'?: undefined; | ||
} | { | ||
'video:content_loc': string; | ||
'video:thumbnail_loc'?: undefined; | ||
'video:title'?: undefined; | ||
'video:description'?: undefined; | ||
'video:player_loc'?: undefined; | ||
'video:duration'?: undefined; | ||
'video:expiration_date'?: undefined; | ||
'video:rating'?: undefined; | ||
'video:view_count'?: undefined; | ||
'video:publication_date'?: undefined; | ||
'video:family_friendly'?: undefined; | ||
'video:restriction'?: undefined; | ||
'video:price'?: undefined; | ||
'video:requires_subscription'?: undefined; | ||
'video:uploader'?: undefined; | ||
'video:live'?: undefined; | ||
} | { | ||
'video:player_loc': string; | ||
'video:thumbnail_loc'?: undefined; | ||
'video:title'?: undefined; | ||
'video:description'?: undefined; | ||
'video:content_loc'?: undefined; | ||
'video:duration'?: undefined; | ||
'video:expiration_date'?: undefined; | ||
'video:rating'?: undefined; | ||
'video:view_count'?: undefined; | ||
'video:publication_date'?: undefined; | ||
'video:family_friendly'?: undefined; | ||
'video:restriction'?: undefined; | ||
'video:price'?: undefined; | ||
'video:requires_subscription'?: undefined; | ||
'video:uploader'?: undefined; | ||
'video:live'?: undefined; | ||
} | { | ||
'video:duration': number; | ||
'video:thumbnail_loc'?: undefined; | ||
'video:title'?: undefined; | ||
'video:description'?: undefined; | ||
'video:content_loc'?: undefined; | ||
'video:player_loc'?: undefined; | ||
'video:expiration_date'?: undefined; | ||
'video:rating'?: undefined; | ||
'video:view_count'?: undefined; | ||
'video:publication_date'?: undefined; | ||
'video:family_friendly'?: undefined; | ||
'video:restriction'?: undefined; | ||
'video:price'?: undefined; | ||
'video:requires_subscription'?: undefined; | ||
'video:uploader'?: undefined; | ||
'video:live'?: undefined; | ||
} | { | ||
'video:expiration_date': string | Date; | ||
'video:thumbnail_loc'?: undefined; | ||
'video:title'?: undefined; | ||
'video:description'?: undefined; | ||
'video:content_loc'?: undefined; | ||
'video:player_loc'?: undefined; | ||
'video:duration'?: undefined; | ||
'video:rating'?: undefined; | ||
'video:view_count'?: undefined; | ||
'video:publication_date'?: undefined; | ||
'video:family_friendly'?: undefined; | ||
'video:restriction'?: undefined; | ||
'video:price'?: undefined; | ||
'video:requires_subscription'?: undefined; | ||
'video:uploader'?: undefined; | ||
'video:live'?: undefined; | ||
} | { | ||
'video:rating': number; | ||
'video:thumbnail_loc'?: undefined; | ||
'video:title'?: undefined; | ||
'video:description'?: undefined; | ||
'video:content_loc'?: undefined; | ||
'video:player_loc'?: undefined; | ||
'video:duration'?: undefined; | ||
'video:expiration_date'?: undefined; | ||
'video:view_count'?: undefined; | ||
'video:publication_date'?: undefined; | ||
'video:family_friendly'?: undefined; | ||
'video:restriction'?: undefined; | ||
'video:price'?: undefined; | ||
'video:requires_subscription'?: undefined; | ||
'video:uploader'?: undefined; | ||
'video:live'?: undefined; | ||
} | { | ||
'video:view_count': number; | ||
'video:thumbnail_loc'?: undefined; | ||
'video:title'?: undefined; | ||
'video:description'?: undefined; | ||
'video:content_loc'?: undefined; | ||
'video:player_loc'?: undefined; | ||
'video:duration'?: undefined; | ||
'video:expiration_date'?: undefined; | ||
'video:rating'?: undefined; | ||
'video:publication_date'?: undefined; | ||
'video:family_friendly'?: undefined; | ||
'video:restriction'?: undefined; | ||
'video:price'?: undefined; | ||
'video:requires_subscription'?: undefined; | ||
'video:uploader'?: undefined; | ||
'video:live'?: undefined; | ||
} | { | ||
'video:publication_date': string | Date; | ||
'video:thumbnail_loc'?: undefined; | ||
'video:title'?: undefined; | ||
'video:description'?: undefined; | ||
'video:content_loc'?: undefined; | ||
'video:player_loc'?: undefined; | ||
'video:duration'?: undefined; | ||
'video:expiration_date'?: undefined; | ||
'video:rating'?: undefined; | ||
'video:view_count'?: undefined; | ||
'video:family_friendly'?: undefined; | ||
'video:restriction'?: undefined; | ||
'video:price'?: undefined; | ||
'video:requires_subscription'?: undefined; | ||
'video:uploader'?: undefined; | ||
'video:live'?: undefined; | ||
} | { | ||
'video:family_friendly': string; | ||
'video:thumbnail_loc'?: undefined; | ||
'video:title'?: undefined; | ||
'video:description'?: undefined; | ||
'video:content_loc'?: undefined; | ||
'video:player_loc'?: undefined; | ||
'video:duration'?: undefined; | ||
'video:expiration_date'?: undefined; | ||
'video:rating'?: undefined; | ||
'video:view_count'?: undefined; | ||
'video:publication_date'?: undefined; | ||
'video:restriction'?: undefined; | ||
'video:price'?: undefined; | ||
'video:requires_subscription'?: undefined; | ||
'video:uploader'?: undefined; | ||
'video:live'?: undefined; | ||
} | { | ||
'video:restriction': (string | { | ||
_attr: { | ||
relationship: "allow" | "deny"; | ||
}; | ||
})[]; | ||
'video:thumbnail_loc'?: undefined; | ||
'video:title'?: undefined; | ||
'video:description'?: undefined; | ||
'video:content_loc'?: undefined; | ||
'video:player_loc'?: undefined; | ||
'video:duration'?: undefined; | ||
'video:expiration_date'?: undefined; | ||
'video:rating'?: undefined; | ||
'video:view_count'?: undefined; | ||
'video:publication_date'?: undefined; | ||
'video:family_friendly'?: undefined; | ||
'video:price'?: undefined; | ||
'video:requires_subscription'?: undefined; | ||
'video:uploader'?: undefined; | ||
'video:live'?: undefined; | ||
} | { | ||
'video:price': (number | { | ||
_attr: { | ||
currency: string; | ||
}; | ||
})[]; | ||
'video:thumbnail_loc'?: undefined; | ||
'video:title'?: undefined; | ||
'video:description'?: undefined; | ||
'video:content_loc'?: undefined; | ||
'video:player_loc'?: undefined; | ||
'video:duration'?: undefined; | ||
'video:expiration_date'?: undefined; | ||
'video:rating'?: undefined; | ||
'video:view_count'?: undefined; | ||
'video:publication_date'?: undefined; | ||
'video:family_friendly'?: undefined; | ||
'video:restriction'?: undefined; | ||
'video:requires_subscription'?: undefined; | ||
'video:uploader'?: undefined; | ||
'video:live'?: undefined; | ||
} | { | ||
'video:requires_subscription': string; | ||
'video:thumbnail_loc'?: undefined; | ||
'video:title'?: undefined; | ||
'video:description'?: undefined; | ||
'video:content_loc'?: undefined; | ||
'video:player_loc'?: undefined; | ||
'video:duration'?: undefined; | ||
'video:expiration_date'?: undefined; | ||
'video:rating'?: undefined; | ||
'video:view_count'?: undefined; | ||
'video:publication_date'?: undefined; | ||
'video:family_friendly'?: undefined; | ||
'video:restriction'?: undefined; | ||
'video:price'?: undefined; | ||
'video:uploader'?: undefined; | ||
'video:live'?: undefined; | ||
} | { | ||
'video:uploader': (string | { | ||
_attr: { | ||
info: string | undefined; | ||
}; | ||
})[]; | ||
'video:thumbnail_loc'?: undefined; | ||
'video:title'?: undefined; | ||
'video:description'?: undefined; | ||
'video:content_loc'?: undefined; | ||
'video:player_loc'?: undefined; | ||
'video:duration'?: undefined; | ||
'video:expiration_date'?: undefined; | ||
'video:rating'?: undefined; | ||
'video:view_count'?: undefined; | ||
'video:publication_date'?: undefined; | ||
'video:family_friendly'?: undefined; | ||
'video:restriction'?: undefined; | ||
'video:price'?: undefined; | ||
'video:requires_subscription'?: undefined; | ||
'video:live'?: undefined; | ||
} | { | ||
'video:live': string; | ||
'video:thumbnail_loc'?: undefined; | ||
'video:title'?: undefined; | ||
'video:description'?: undefined; | ||
'video:content_loc'?: undefined; | ||
'video:player_loc'?: undefined; | ||
'video:duration'?: undefined; | ||
'video:expiration_date'?: undefined; | ||
'video:rating'?: undefined; | ||
'video:view_count'?: undefined; | ||
'video:publication_date'?: undefined; | ||
'video:family_friendly'?: undefined; | ||
'video:restriction'?: undefined; | ||
'video:price'?: undefined; | ||
'video:requires_subscription'?: undefined; | ||
'video:uploader'?: undefined; | ||
})[]; | ||
}; | ||
export declare const getUrlXml: (entry: SitemapEntry) => string; | ||
export type GetEntryXmlParams = { | ||
config: RemixSitemapConfig; | ||
entry?: SitemapEntry; | ||
}; | ||
export declare function getEntryXml({ config, entry }: GetEntryXmlParams): string; | ||
export declare const getBooleanValue: (value: boolean) => "yes" | "no"; | ||
export declare function getOptionalValue<T>(value: any | undefined, returnType: T): T | undefined; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getEntryXml = exports.getUrlXml = exports.getVideo = exports.getNews = exports.getImage = exports.getAlternateRef = void 0; | ||
const ufo_1 = require("ufo"); | ||
const xml_1 = __importDefault(require("xml")); | ||
const truthy_1 = require("./truthy"); | ||
const getAlternateRef = (alternateRefs) => ({ | ||
'xhtml:link': { | ||
_attr: { | ||
rel: 'alternate', | ||
hreflang: alternateRefs.hreflang, | ||
href: (0, ufo_1.cleanDoubleSlashes)(alternateRefs.href) | ||
} | ||
exports.getOptionalValue = exports.getBooleanValue = void 0; | ||
const getBooleanValue = (value) => (value ? 'yes' : 'no'); | ||
exports.getBooleanValue = getBooleanValue; | ||
function getOptionalValue(value, returnType) { | ||
if (value) { | ||
return returnType; | ||
} | ||
}); | ||
exports.getAlternateRef = getAlternateRef; | ||
const getImage = (image) => ({ | ||
'image:image': [ | ||
{ | ||
'image:loc': image.loc | ||
} | ||
] | ||
}); | ||
exports.getImage = getImage; | ||
const getNews = (news) => ({ | ||
'news:news': [ | ||
{ | ||
'news:publication': [ | ||
{ | ||
'news:name': news.publication.name | ||
}, | ||
{ | ||
'news:language': news.publication.language | ||
} | ||
] | ||
}, | ||
{ | ||
'news:publication_date': news.date | ||
}, | ||
{ | ||
'news:title': news.title | ||
} | ||
] | ||
}); | ||
exports.getNews = getNews; | ||
const getVideo = (video) => { | ||
var _a, _b, _c, _d, _e, _f; | ||
return ({ | ||
'video:video': [ | ||
{ | ||
'video:thumbnail_loc': video.thumbnailLoc | ||
}, | ||
{ | ||
'video:title': video.title | ||
}, | ||
{ | ||
'video:description': video.description | ||
}, | ||
{ | ||
'video:content_loc': video.contentLoc | ||
}, | ||
{ | ||
'video:player_loc': video.playerLoc | ||
}, | ||
video.duration && { | ||
'video:duration': video.duration | ||
}, | ||
video.expirationDate && { | ||
'video:expiration_date': video.expirationDate | ||
}, | ||
video.rating && { | ||
'video:rating': video.rating | ||
}, | ||
video.viewCount && { | ||
'video:view_count': video.viewCount | ||
}, | ||
video.publicationDate && { | ||
'video:publication_date': video.publicationDate | ||
}, | ||
typeof video.familyFriendly !== 'undefined' && { | ||
'video:family_friendly': video.familyFriendly ? 'yes' : 'no' | ||
}, | ||
video.restriction && { | ||
'video:restriction': [ | ||
{ | ||
_attr: { | ||
relationship: (_a = video.restriction) === null || _a === void 0 ? void 0 : _a.relationship | ||
} | ||
}, | ||
(_b = video.restriction) === null || _b === void 0 ? void 0 : _b.countries.join(' ') | ||
] | ||
}, | ||
video.price && { | ||
'video:price': [ | ||
{ | ||
_attr: { | ||
currency: (_c = video.price) === null || _c === void 0 ? void 0 : _c.currency | ||
} | ||
}, | ||
(_d = video.price) === null || _d === void 0 ? void 0 : _d.value | ||
] | ||
}, | ||
typeof video.requiresSubscription !== 'undefined' && { | ||
'video:requires_subscription': video.requiresSubscription ? 'yes' : 'no' | ||
}, | ||
video.uploader && { | ||
'video:uploader': [ | ||
{ | ||
_attr: { | ||
info: (_e = video.uploader) === null || _e === void 0 ? void 0 : _e.info | ||
} | ||
}, | ||
(_f = video.uploader) === null || _f === void 0 ? void 0 : _f.name | ||
] | ||
}, | ||
typeof video.live !== 'undefined' && { | ||
'video:live': video.live ? 'yes' : 'no' | ||
}, | ||
...(video.tags || []).map(tag => ({ | ||
'video:tag': tag | ||
})) | ||
].filter(truthy_1.truthy) | ||
}); | ||
}; | ||
exports.getVideo = getVideo; | ||
const getUrlXml = (entry) => { | ||
const url = [ | ||
{ | ||
loc: (0, ufo_1.cleanDoubleSlashes)(entry.loc) | ||
}, | ||
entry.lastmod && { | ||
lastmod: entry.lastmod | ||
}, | ||
entry.changefreq && { | ||
changefreq: entry.changefreq | ||
}, | ||
entry.priority && { | ||
priority: entry.priority | ||
}, | ||
...(entry.alternateRefs || []).map(exports.getAlternateRef), | ||
...(entry.images || []).map(exports.getImage), | ||
...(entry.news || []).map(exports.getNews), | ||
...(entry.videos || []).map(exports.getVideo) | ||
].filter(truthy_1.truthy); | ||
return (0, xml_1.default)({ url }); | ||
}; | ||
exports.getUrlXml = getUrlXml; | ||
function getEntryXml({ config, entry }) { | ||
var _a, _b, _c, _d; | ||
const alternateRefs = (_a = ((entry === null || entry === void 0 ? void 0 : entry.alternateRefs) || config.alternateRefs)) === null || _a === void 0 ? void 0 : _a.map(ref => ({ | ||
...ref, | ||
href: ref.absolute ? ref.href : `${ref.href}/${entry === null || entry === void 0 ? void 0 : entry.loc}` | ||
})); | ||
return (0, exports.getUrlXml)({ | ||
loc: `${config.siteUrl}/${entry === null || entry === void 0 ? void 0 : entry.loc}`, | ||
lastmod: config.autoLastmod | ||
? (_b = entry === null || entry === void 0 ? void 0 : entry.lastmod) !== null && _b !== void 0 ? _b : new Date().toISOString() | ||
: entry === null || entry === void 0 ? void 0 : entry.lastmod, | ||
changefreq: (_c = entry === null || entry === void 0 ? void 0 : entry.changefreq) !== null && _c !== void 0 ? _c : config.changefreq, | ||
priority: (_d = entry === null || entry === void 0 ? void 0 : entry.priority) !== null && _d !== void 0 ? _d : config.priority, | ||
alternateRefs, | ||
videos: entry === null || entry === void 0 ? void 0 : entry.videos, | ||
images: entry === null || entry === void 0 ? void 0 : entry.images, | ||
news: entry === null || entry === void 0 ? void 0 : entry.news | ||
}); | ||
return undefined; | ||
} | ||
exports.getEntryXml = getEntryXml; | ||
exports.getOptionalValue = getOptionalValue; |
{ | ||
"name": "remix-sitemap", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"private": false, | ||
@@ -17,3 +17,9 @@ "bin": { | ||
}, | ||
"keywords": [], | ||
"keywords": [ | ||
"remix", | ||
"sitemap", | ||
"seo", | ||
"sitemap.xml", | ||
"sitemap-generator" | ||
], | ||
"author": { | ||
@@ -30,3 +36,2 @@ "name": "Federico Minaya", | ||
"@types/require-from-string": "^1.2.1", | ||
"@types/xml": "^1.0.8", | ||
"@vitest/coverage-c8": "^0.29.8", | ||
@@ -43,6 +48,6 @@ "@vitest/ui": "^0.29.8", | ||
"esbuild": "^0.17.11", | ||
"fast-xml-parser": "^4.1.3", | ||
"isomorphic-fetch": "^3.0.0", | ||
"require-from-string": "^2.0.2", | ||
"ufo": "^1.1.1", | ||
"xml": "^1.0.1" | ||
"ufo": "^1.1.1" | ||
}, | ||
@@ -49,0 +54,0 @@ "types": "./dist/index.d.ts", |
@@ -25,2 +25,3 @@ <h1>Remix Sitemap</h1> | ||
- Build time Generation (Experimental) | ||
- Generate `robots.txt` | ||
- Handle Static Optional Paths | ||
@@ -27,0 +28,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8
42
246
71596
1161
+ Addedfast-xml-parser@^4.1.3
+ Addedfast-xml-parser@4.5.0(transitive)
+ Addedstrnum@1.0.5(transitive)
- Removedxml@^1.0.1
- Removedxml@1.0.1(transitive)