MCPcopy Create free account
hub / github.com/chokcoco/iCSS / saveToDatabase

Method saveToDatabase

MCP/scripts/fetch-inspiration.js:334–380  ·  view source on GitHub ↗
(category, filename, parsedContent)

Source from the content-addressed store, hash-verified

332 }
333
334 async saveToDatabase(category, filename, parsedContent) {
335 const insertSQL = `
336 INSERT OR REPLACE INTO css_inspiration
337 (category, filename, title, description, html_content, css_content,
338 demo_url, source_url, tags, difficulty_level, browser_support,
339 search_content, updated_at)
340 VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)
341 `;
342
343 const sourceUrl = `https://github.com/chokcoco/CSS-Inspiration/blob/master/${category}/${filename}`;
344 const demoUrl = `https://chokcoco.github.io/CSS-Inspiration/${category}/${filename.replace('.md', '.html')}`;
345
346 const searchContent = [
347 parsedContent.title,
348 parsedContent.description,
349 category,
350 this.categoryMapping[category] || category,
351 ...JSON.parse(parsedContent.tags)
352 ].join(' ');
353
354 return new Promise((resolve, reject) => {
355 this.db.run(
356 insertSQL,
357 [
358 category,
359 filename,
360 parsedContent.title,
361 parsedContent.description,
362 parsedContent.htmlContent,
363 parsedContent.cssContent,
364 demoUrl,
365 sourceUrl,
366 parsedContent.tags,
367 parsedContent.difficultyLevel,
368 parsedContent.browserSupport,
369 searchContent
370 ],
371 function(err) {
372 if (err) {
373 reject(err);
374 } else {
375 resolve(this.lastID);
376 }
377 }
378 );
379 });
380 }
381
382 async extractAndSaveCodeSnippets(inspirationId, htmlContent, cssContent) {
383 if (!htmlContent && !cssContent) return;

Callers 1

fetchAllInspirationsMethod · 0.95

Calls 1

runMethod · 0.45

Tested by

no test coverage detected