gatsby-theme-advanced
Version:
GatsbyJS theme equipped with advanced features.
43 lines (42 loc) • 1.92 kB
JavaScript
;
/* eslint "no-console": "off" */
Object.defineProperty(exports, "__esModule", { value: true });
exports.setup = exports.getSerialize = void 0;
const getSerialize = (config) => (data) => {
const { query: { allMdx }, } = data;
const edges = allMdx === null || allMdx === void 0 ? void 0 : allMdx.edges;
if (!edges) {
console.warn("No Mdx edges available for feed generation.");
return undefined;
}
const res = edges.map((edge) => {
var _a, _b, _c, _d, _e;
const { node } = edge;
const slug = (_a = node.fields) === null || _a === void 0 ? void 0 : _a.slug;
const url = slug ? config.website.url + slug : config.website.url;
return {
categories: (_b = node === null || node === void 0 ? void 0 : node.frontmatter) === null || _b === void 0 ? void 0 : _b.tags,
date: (_c = node === null || node === void 0 ? void 0 : node.frontmatter) === null || _c === void 0 ? void 0 : _c.datePublished,
title: (_d = node === null || node === void 0 ? void 0 : node.frontmatter) === null || _d === void 0 ? void 0 : _d.title,
description: node.excerpt,
url,
guid: url,
custom_elements: [
{ "content:encoded": node.html },
{ author: (_e = config.user) === null || _e === void 0 ? void 0 : _e.email },
],
};
});
return res;
};
exports.getSerialize = getSerialize;
const setup = (ref) => {
var _a, _b, _c;
const ret = (_c = (_b = (_a = ref.query) === null || _a === void 0 ? void 0 : _a.site) === null || _b === void 0 ? void 0 : _b.siteMetadata) === null || _c === void 0 ? void 0 : _c.rssMetadata;
if (!ret) {
throw Error("gatsby-plugin-feed rssMetadata is missing. Aborting feed setup.");
}
ret.generator = "GatsbyJS Advanced Starter";
return ret;
};
exports.setup = setup;