[docs] Fix missing Persistence page (#2828)
Fixes #2826, extracted from #2680 The problem is that we had two different articles whose ids were being derived as `persistence`, the `persistence.mdx` file and the `persistence/` example. I've 1. Made it an error for two articles to have the same id 2. Renamed the `persistence/` article to `local-storage` since that's the API it's using. ### Change Type - [ ] `patch` — Bug fix - [ ] `minor` — New feature - [ ] `major` — Breaking change - [ ] `dependencies` — Changes to package dependencies[^1] - [x] `documentation` — Changes to the documentation only[^2] - [ ] `tests` — Changes to any test code only[^2] - [ ] `internal` — Any other changes that don't affect the published package[^2] - [ ] I don't know [^1]: publishes a `patch` release, for devDependencies use `internal` [^2]: will not publish a new version ### Test Plan 1. Add a step-by-step description of how to test your PR here. 3. - [ ] Unit Tests - [ ] End to end tests ### Release Notes - Add a brief release note for your PR here.
This commit is contained in:
parent
ad5a61879a
commit
9d895aab13
5 changed files with 35 additions and 28 deletions
|
@ -8,19 +8,19 @@ export async function addContentToDb(
|
||||||
content: GeneratedContent
|
content: GeneratedContent
|
||||||
) {
|
) {
|
||||||
const sectionInsert = await db.prepare(
|
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(
|
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(
|
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(
|
const articleInsert = await db.prepare(
|
||||||
`REPLACE INTO articles (
|
`INSERT INTO articles (
|
||||||
id,
|
id,
|
||||||
groupIndex,
|
groupIndex,
|
||||||
categoryIndex,
|
categoryIndex,
|
||||||
|
@ -79,27 +79,32 @@ export async function addContentToDb(
|
||||||
throw Error(`hey, article ${article.id} has no id`)
|
throw Error(`hey, article ${article.id} has no id`)
|
||||||
}
|
}
|
||||||
|
|
||||||
await articleInsert.run(
|
try {
|
||||||
article.id,
|
await articleInsert.run(
|
||||||
article.groupIndex,
|
article.id,
|
||||||
article.categoryIndex,
|
article.groupIndex,
|
||||||
article.sectionIndex,
|
article.categoryIndex,
|
||||||
article.groupId,
|
article.sectionIndex,
|
||||||
article.categoryId,
|
article.groupId,
|
||||||
article.sectionId,
|
article.categoryId,
|
||||||
article.author,
|
article.sectionId,
|
||||||
article.title,
|
article.author,
|
||||||
article.description,
|
article.title,
|
||||||
article.hero,
|
article.description,
|
||||||
article.status,
|
article.hero,
|
||||||
article.date,
|
article.status,
|
||||||
article.sourceUrl,
|
article.date,
|
||||||
article.componentCode,
|
article.sourceUrl,
|
||||||
article.componentCodeFiles,
|
article.componentCode,
|
||||||
article.keywords.join(', '),
|
article.componentCodeFiles,
|
||||||
article.content,
|
article.keywords.join(', '),
|
||||||
article.path
|
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)
|
await db.run(`DELETE FROM headings WHERE articleId = ?`, article.id)
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ import { refreshContent } from './scripts/functions/refreshContent'
|
||||||
import { debounce } from './utils/debounce'
|
import { debounce } from './utils/debounce'
|
||||||
import { nicelog } from './utils/nicelog'
|
import { nicelog } from './utils/nicelog'
|
||||||
|
|
||||||
|
refreshContent({ silent: true })
|
||||||
|
|
||||||
fs.watch(
|
fs.watch(
|
||||||
'content',
|
'content',
|
||||||
{ persistent: true, recursive: true },
|
{ persistent: true, recursive: true },
|
||||||
|
|
|
@ -67,7 +67,7 @@ test.describe('Routes', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('persistence', async ({ page }) => {
|
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')
|
await page.waitForSelector('.tl-canvas')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
title: Persistence
|
title: Local Storage
|
||||||
component: ./PersistenceExample.tsx
|
component: ./LocalStorageExample.tsx
|
||||||
category: data/assets
|
category: data/assets
|
||||||
---
|
---
|
||||||
|
|
Loading…
Reference in a new issue