feat: add online FAQ/KB sync without old bridge
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { parseFrontmatter, splitChunks, createParentChildChunks } = require('../src/kb-chunker');
|
||||
|
||||
test('kb chunker: parse frontmatter and split Q/A', () => {
|
||||
const md = `---\ntitle: Test\ncategory: test\nkeywords: [ring, gold]\nsource_url: https://www.yehwang.com/x.html\n---\n## Section\n### Q: What is it?\nLong answer ${'x'.repeat(600)}\n`;
|
||||
const { meta, body } = parseFrontmatter(md);
|
||||
assert.equal(meta.title, 'Test');
|
||||
assert.deepEqual(meta.keywords, ['ring', 'gold']);
|
||||
const chunks = splitChunks(body);
|
||||
assert.equal(chunks.length, 1);
|
||||
const { parent, children } = createParentChildChunks(chunks[0], meta, '01-test.md');
|
||||
assert.equal(parent.question, 'What is it?');
|
||||
assert.equal(parent.source_urls[0], 'https://www.yehwang.com/x.html');
|
||||
assert.equal(children.length, 2);
|
||||
});
|
||||
Reference in New Issue
Block a user