Skip to content
This repository was archived by the owner on Feb 11, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/app/api/local/pr/knowledge/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { NextRequest } from 'next/server';
import * as git from 'isomorphic-git';
import fs from 'fs';
import path from 'path';
import { dumpYaml } from '@/utils/yamlConfig';
import { KnowledgeYamlData } from '@/types';
import yaml from 'js-yaml';

// Define paths and configuration
Expand All @@ -13,18 +15,20 @@ const KNOWLEDGE_DIR = 'knowledge';

export async function POST(req: NextRequest) {
try {
// Extract the QnA data from the request body TODO: what is documentOutline?
const { content, attribution, name, email, submissionSummary, documentOutline, filePath } = await req.json(); // eslint-disable-line @typescript-eslint/no-unused-vars
// Extract the data from the request body
const { content, attribution, name, email, submissionSummary, filePath } = await req.json();

// Parse the YAML string into an object
const knowledgeData = yaml.load(content) as KnowledgeYamlData;

// Convert the object to YAML
const yamlString = dumpYaml(knowledgeData);

// Define branch name and file paths
const branchName = `knowledge-contribution-${Date.now()}`;
const newYamlFilePath = path.join(KNOWLEDGE_DIR, filePath, 'qna.yaml');
const newAttributionFilePath = path.join(KNOWLEDGE_DIR, filePath, 'attribution.txt');

// Convert data to YAML and plain text formats
const yamlString = yaml.dump(content);
const attributionContent = `
Title of work: ${attribution.title_of_work}
const attributionContent = `Title of work: ${attribution.title_of_work}
Link to work: ${attribution.link_to_work}
Revision: ${attribution.revision}
License of the work: ${attribution.license_of_the_work}
Expand Down