import xml2js from 'xml2js'; export const title = 'My RSS feed'; export const description = 'This sure is a nice RSS feed'; export const site = 'https://example.com'; export const phpFeedItem = { link: '/php', title: 'Remember PHP?', pubDate: '1994-05-03', description: 'PHP is a general-purpose scripting language geared toward web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1994.', }; export const phpFeedItemWithContent = { ...phpFeedItem, content: `
${phpFeedItem.description}
`, }; export const phpFeedItemWithCustomData = { ...phpFeedItem, customData: '${web1FeedItem.description}
`, }; export const web1FeedItemWithAllData = { ...web1FeedItem, categories: ['web1', 'history'], author: 'test@example.com', commentsUrl: 'http://example.com/comments', source: { url: 'http://example.com/source', title: 'The Web 1.0 blog', }, enclosure: { url: '/podcast.mp3', length: 256, type: 'audio/mpeg', }, }; const parser = new xml2js.Parser({ trim: true }); /** * * Utility function to parse an XML string into an object using `xml2js`. * * @param {string} xmlString - Stringified XML to parse. * @return {{ err: Error, result: any }} Represents an option containing the parsed XML string or an Error. */ export function parseXmlString(xmlString) { let res; parser.parseString(xmlString, (err, result) => { res = { err, result }; }); return res; }