MCPcopy Create free account
hub / github.com/pollinations/pollinations / parseProjects

Function parseProjects

apps/gsoc/src/utils/parseProjects.js:13–41  ·  view source on GitHub ↗
(url = "/GSOC/PROJECTS.md")

Source from the content-addressed store, hash-verified

11 * Description content here.
12 */
13export async function parseProjects(url = "/GSOC/PROJECTS.md") {
14 const response = await fetch(url);
15 const text = await response.text();
16
17 // Match complete frontmatter blocks: ---\nyaml\n---\nbody
18 // Each match captures: full block with frontmatter + body until next --- or end
19 const regex = /---\n([\s\S]*?)\n---\n([\s\S]*?)(?=\n---\n|$)/g;
20 const projects = [];
21
22 for (const match of text.matchAll(regex)) {
23 const [, yaml, body] = match;
24 // Reconstruct as valid frontmatter string for fm()
25 const fmString = `---\n${yaml}\n---\n${body}`;
26 const { attributes } = fm(fmString);
27
28 if (attributes.title) {
29 const paragraphs = body.trim().split("\n\n").filter(Boolean);
30 projects.push({
31 ...attributes,
32 technologies: attributes.technologies?.split(", ") || [],
33 description: paragraphs[0] || "",
34 longDescription:
35 paragraphs.slice(1).join("\n\n") || paragraphs[0] || "",
36 });
37 }
38 }
39
40 return projects;
41}

Callers 1

ProjectsPageFunction · 0.90

Calls 5

fmFunction · 0.85
pushMethod · 0.80
sliceMethod · 0.80
textMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected