diff --git a/apps/docs/utils/addContent.ts b/apps/docs/utils/addContent.ts index 76e2732a0..3da123ada 100644 --- a/apps/docs/utils/addContent.ts +++ b/apps/docs/utils/addContent.ts @@ -8,19 +8,19 @@ export async function addContentToDb( content: GeneratedContent ) { const sectionInsert = await db.prepare( - `REPLACE INTO sections (id, idx, title, description, path, sidebar_behavior) VALUES (?, ?, ?, ?, ?, ?)` + `INSERT INTO sections (id, idx, title, description, path, sidebar_behavior) VALUES (?, ?, ?, ?, ?, ?)` ) const categoryInsert = await db.prepare( - `REPLACE INTO categories (id, title, description, sectionId, sectionIndex, path) VALUES (?, ?, ?, ?, ?, ?)` + `INSERT INTO categories (id, title, description, sectionId, sectionIndex, path) VALUES (?, ?, ?, ?, ?, ?)` ) const headingsInsert = await db.prepare( - `REPLACE INTO headings (idx, articleId, level, title, slug, isCode, path) VALUES (?, ?, ?, ?, ?, ?, ?)` + `INSERT INTO headings (idx, articleId, level, title, slug, isCode, path) VALUES (?, ?, ?, ?, ?, ?, ?)` ) const articleInsert = await db.prepare( - `REPLACE INTO articles ( + `INSERT INTO articles ( id, groupIndex, categoryIndex, @@ -79,27 +79,32 @@ export async function addContentToDb( throw Error(`hey, article ${article.id} has no id`) } - await articleInsert.run( - article.id, - article.groupIndex, - article.categoryIndex, - article.sectionIndex, - article.groupId, - article.categoryId, - article.sectionId, - article.author, - article.title, - article.description, - article.hero, - article.status, - article.date, - article.sourceUrl, - article.componentCode, - article.componentCodeFiles, - article.keywords.join(', '), - article.content, - article.path - ) + try { + await articleInsert.run( + article.id, + article.groupIndex, + article.categoryIndex, + article.sectionIndex, + article.groupId, + article.categoryId, + article.sectionId, + article.author, + article.title, + article.description, + article.hero, + article.status, + article.date, + article.sourceUrl, + article.componentCode, + article.componentCodeFiles, + article.keywords.join(', '), + article.content, + article.path + ) + } catch (e: any) { + console.error(`ERROR: Could not add article with id '${article.id}'`) + throw e + } await db.run(`DELETE FROM headings WHERE articleId = ?`, article.id) diff --git a/apps/docs/watcher.ts b/apps/docs/watcher.ts index 8d486d3b7..46b1a339c 100644 --- a/apps/docs/watcher.ts +++ b/apps/docs/watcher.ts @@ -5,6 +5,8 @@ import { refreshContent } from './scripts/functions/refreshContent' import { debounce } from './utils/debounce' import { nicelog } from './utils/nicelog' +refreshContent({ silent: true }) + fs.watch( 'content', { persistent: true, recursive: true }, diff --git a/apps/examples/e2e/tests/test-routes.spec.ts b/apps/examples/e2e/tests/test-routes.spec.ts index dffae7677..ed0f5d3f5 100644 --- a/apps/examples/e2e/tests/test-routes.spec.ts +++ b/apps/examples/e2e/tests/test-routes.spec.ts @@ -67,7 +67,7 @@ test.describe('Routes', () => { }) test('persistence', async ({ page }) => { - await page.goto('http://localhost:5420/persistence/full') + await page.goto('http://localhost:5420/local-storage/full') await page.waitForSelector('.tl-canvas') }) diff --git a/apps/examples/src/examples/persistence/PersistenceExample.tsx b/apps/examples/src/examples/local-storage/LocalStorageExample.tsx similarity index 100% rename from apps/examples/src/examples/persistence/PersistenceExample.tsx rename to apps/examples/src/examples/local-storage/LocalStorageExample.tsx diff --git a/apps/examples/src/examples/persistence/README.md b/apps/examples/src/examples/local-storage/README.md similarity index 77% rename from apps/examples/src/examples/persistence/README.md rename to apps/examples/src/examples/local-storage/README.md index c72d9d430..b45caa322 100644 --- a/apps/examples/src/examples/persistence/README.md +++ b/apps/examples/src/examples/local-storage/README.md @@ -1,6 +1,6 @@ --- -title: Persistence -component: ./PersistenceExample.tsx +title: Local Storage +component: ./LocalStorageExample.tsx category: data/assets ---