Skip to content

Commit

Permalink
Merge branch 'dev' into event-stream
Browse files Browse the repository at this point in the history
  • Loading branch information
smk762 committed Sep 9, 2024
2 parents e23904e + 05eeeb0 commit 7e7f6db
Show file tree
Hide file tree
Showing 18 changed files with 85,964 additions and 95,768 deletions.
61,548 changes: 28,825 additions & 32,723 deletions data-for-gpts/all-content.txt

Large diffs are not rendered by default.

15,974 changes: 7,418 additions & 8,556 deletions data-for-gpts/antara-content.txt

Large diffs are not rendered by default.

84 changes: 25 additions & 59 deletions data-for-gpts/historical-content.txt

Large diffs are not rendered by default.

30,290 changes: 14,499 additions & 15,791 deletions data-for-gpts/komodefi-api/all-api-content.txt

Large diffs are not rendered by default.

12,040 changes: 5,808 additions & 6,232 deletions data-for-gpts/komodefi-api/legacy-api-content.txt

Large diffs are not rendered by default.

8,162 changes: 3,945 additions & 4,217 deletions data-for-gpts/komodefi-api/v20-api-content.txt

Large diffs are not rendered by default.

7,882 changes: 3,731 additions & 4,151 deletions data-for-gpts/komodefi-api/v20-dev-api-content.txt

Large diffs are not rendered by default.

32,463 changes: 15,586 additions & 16,877 deletions data-for-gpts/komodo-defi-framework-content.txt

Large diffs are not rendered by default.

12,536 changes: 5,727 additions & 6,809 deletions data-for-gpts/smart-chains-content.txt

Large diffs are not rendered by default.

373 changes: 129 additions & 244 deletions data-for-gpts/start-here-content.txt

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions filepathSlugs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3578,12 +3578,16 @@
"src/pages/komodo-defi-framework/changelog/index.mdx": [
"change-log",
"komodo-de-fi-framework-v2-1-0-beta",
"essential-new-features-trading-protocol-upgrade-hd-wallet-event-streaming-and-seeds-management",
"release-notes",
"features",
"enhancements-fixes",
"nb-backwards-compatibility-breaking-changes",
"new-contributors",
"enhancements",
"bug-fixes",
"komodo-de-fi-framework-v2-0-0-beta",
"network-evolution-and-kmd-burn-enhancing-kmds-role-in-komodos-de-fi-framework",
"release-notes",
"release-notes-2",
"nb-backwards-compatibility-breaking-changes-2",
"komodo-de-fi-framework-v1-0-7-beta",
"komodo-de-fi-framework-v1-0-6-beta",
Expand Down
Binary file modified preview-images/optimized/pre-komodo-defi-framework-changelog.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified preview-images/original/pre-komodo-defi-framework-changelog.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion preview-images/previewImgTimeStamps.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
"/komodo-defi-framework/api/v20-dev/zhtlc_coins/activation": "2024-07-08T12:16:22.000Z",
"/komodo-defi-framework/api/v20-dev/zhtlc_coins": "2024-03-08T15:53:57.000Z",
"/komodo-defi-framework/api/v20-dev/zhtlc_coins/transaction_history": "2024-03-12T16:57:58.000Z",
"/komodo-defi-framework/changelog": "2024-03-08T15:53:57.000Z",
"/komodo-defi-framework/changelog": "2024-08-02T13:26:41.000Z",
"/komodo-defi-framework": "2024-04-11T16:31:02.000Z",
"/komodo-defi-framework/setup/configure-mm2-json": "2024-03-11T05:04:37.000Z",
"/komodo-defi-framework/setup": "2024-06-14T01:07:38.000Z",
Expand Down
238 changes: 145 additions & 93 deletions src/pages/komodo-defi-framework/changelog/index.mdx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion utils/_fileData.json
Original file line number Diff line number Diff line change
Expand Up @@ -5210,7 +5210,7 @@
}
},
"/komodo-defi-framework/changelog": {
"dateModified": "2024-03-08T15:53:57.000Z",
"dateModified": "2024-08-02T13:26:41.000Z",
"contributors": [
{
"name": "\"gcharang\"",
Expand Down
2 changes: 1 addition & 1 deletion utils/_searchIndex.json

Large diffs are not rendered by default.

128 changes: 117 additions & 11 deletions utils/js/create_data_for_gpts.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,136 @@
import * as fs from "fs";
import * as path from "path";
//import { EXIT, visitParents } from 'unist-util-visit-parents'
import { visit, EXIT } from 'unist-util-visit'
import path from 'path'
import { remark } from 'remark'
import remarkGfm from "remark-gfm";
import remarkMdx from "remark-mdx";


function walkDir(dirPath, callback, ...callbackArgs) {
fs.readdirSync(dirPath).forEach((file) => {
const filePath = path.join(dirPath, file);
async function walkDir(dir, callback, ...callbackArgs) {
let files = fs.readdirSync(dir);

for (const file of files) {
const filePath = path.join(dir, file);
const stat = fs.statSync(filePath);

if (stat.isDirectory()) {
walkDir(filePath, callback, ...callbackArgs);
} else {
callback(filePath, ...callbackArgs);
await walkDir(filePath, callback, ...callbackArgs);
} else if (stat.isFile() && !filePath.toLowerCase().includes(".ds_store")) {
await callback(filePath, ...callbackArgs);
}
});
}
}

function readFileAndAddContentToFIle(filePath, contentHolder) {
async function readFileProcessItAndAddContentToFile(filePath, contentHolder) {
const fileContent = fs.readFileSync(filePath, 'utf8')
contentHolder.content += fileContent;
const processedFileContent = await convertMdxToMd(fileContent, filePath)
contentHolder.content += processedFileContent;
}

const pathsNames = [["", "all"], ["komodo-defi-framework", "komodo-defi-framework"], ["historical", "historical"], ["smart-chains", "smart-chains"], ["antara", "antara"], ["start-here", "start-here"], ["komodo-defi-framework/api", "komodefi-api/all-api"], ["komodo-defi-framework/api/legacy", "komodefi-api/legacy-api"], ["komodo-defi-framework/api/v20", "komodefi-api/v20-api"], ["komodo-defi-framework/api/v20-dev", "komodefi-api/v20-dev-api"]]

for (let index = 0; index < pathsNames.length; index++) {
const element = pathsNames[index];
let contentHolder = { content: "" };
walkDir(`./src/pages/${element[0]}`, readFileAndAddContentToFIle, contentHolder)
await walkDir(`./src/pages/${element[0]}`, readFileProcessItAndAddContentToFile, contentHolder)
fs.writeFileSync(`./data-for-gpts/${element[1]}-content.txt`, contentHolder.content)
}

async function convertMdxToMd(fileContent, filePath) {
try {
const mdContent = await remark()
.use(remarkGfm)
.use(remarkMdx)
.use(() => (tree) => {

visit(tree, 'mdxJsxFlowElement', (node, index, parent) => {

if (node.name === 'BulletPoints') {
const titleProp = node.attributes.find(attr => attr.name === 'title');
const descProp = node.attributes.find(attr => attr.name === 'desc');

const newContent = [];

if (titleProp && titleProp.value) {
newContent.push({
type: 'heading',
depth: 3,
children: [{ type: 'text', value: titleProp.value }]
});
}


if (descProp && descProp.value && descProp.value.type === 'mdxJsxAttributeValueExpression') {
try {
const markdown = convertHtmlToMd(descProp.value.value);
newContent.push({
type: 'paragraph',
children: [{ type: 'text', value: markdown }]
});
} catch (error) {
console.error(error)
throw new Error(`Error parsing descProp in file: ${filePath}`, error);
}
}

if (newContent.length > 0) {
parent.children.splice(index, 1, ...newContent);
return [visit.SKIP, index];
} else {
parent.children.splice(index, 1);
return [visit.SKIP, index];
}
}

if (node.children && node.children.length > 0) {
parent.children.splice(index, 1, ...node.children);
return [visit.SKIP, index];
} else {
parent.children.splice(index, 1);
return [visit.SKIP, index];
}
});

visit(tree, 'mdxJsxTextElement', (node, index, parent) => {
if (node.children && node.children.length > 0) {
parent.children.splice(index, 1, ...node.children);
return [visit.SKIP, index];
} else {
parent.children.splice(index, 1);
return [visit.SKIP, index];
}
});



})
.process(fileContent);

return mdContent
} catch (error) {
if (error) {
throw new Error(`Error in file: ${filePath} \n ${error}`);
};
}
}

function convertHtmlToMd(html) {
// Remove leading/trailing whitespace and newlines
html = html.trim();

// Replace <ul> and </ul> tags
html = html.replace(/<\/?ul>/g, '');

// Replace <li> tags with Markdown list items
html = html.replace(/<li>/g, '- ');

// Remove </li> tags
html = html.replace(/<\/li>/g, '');

// Trim each line and remove empty lines
const lines = html.split('\n').map(line => line.trim()).filter(line => line !== '');

// Join the lines with newline characters
return lines.join('\n');
}

0 comments on commit 7e7f6db

Please sign in to comment.