MCPcopy Index your code
hub / github.com/adobe/react-spectrum / createFeed

Function createFeed

scripts/createFeedS2.mjs:29–109  ·  view source on GitHub ↗
(library, type, title)

Source from the content-addressed store, hash-verified

27createFeed('s2', 'releases', 'React Spectrum Releases');
28
29function createFeed(library, type, title) {
30 let files = globSync(`packages/dev/s2-docs/pages/${library}/${type}/*.mdx`, {
31 ignore: [`packages/dev/s2-docs/pages/${library}/${type}/index.mdx`]
32 });
33 let posts = [];
34
35 for (let file of files) {
36 let contents = fs.readFileSync(file, 'utf8');
37 let tree = unified().use(remarkParse).use(remarkMdx).parse(contents);
38
39 let exports = {};
40 visit(tree, 'mdxjsEsm', node => {
41 for (let stmt of node.data.estree.body) {
42 if (stmt.type === 'ExportNamedDeclaration') {
43 for (let decl of stmt.declaration.declarations) {
44 if (decl.init.type === 'Literal') {
45 exports[decl.id.name] = decl.init.value;
46 }
47 }
48 }
49 }
50 });
51
52 let title;
53 visit(tree, 'heading', node => {
54 if (node.depth === 1) {
55 title = node.children[0].value;
56 }
57 });
58
59 let summary = unified()
60 .use(remarkParse)
61 .use(remarkMdx)
62 .use(remarkRehype)
63 .use(rehypeStringify)
64 .processSync({value: exports.description}).value;
65
66 let entry = [
67 {title},
68 {
69 link: [
70 {
71 _attr: {
72 rel: 'alternate',
73 type: 'text/html',
74 href: `${getBaseUrl(library)}/${type}/${basename(file, '.mdx')}.html`
75 }
76 }
77 ]
78 },
79 {id: basename(file, '.mdx')},
80 {updated: new Date(exports.date).toISOString()},
81 {published: new Date(exports.date).toISOString()},
82 {summary: [{_attr: {type: 'text/html'}}, summary]}
83 ];
84
85 if (exports.author) {
86 entry.push({

Callers 1

createFeedS2.mjsFile · 0.85

Calls 5

getBaseUrlFunction · 0.90
pushMethod · 0.80
visitFunction · 0.70
sortMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected