bump docubook version 1.13.6
This commit is contained in:
@@ -1,76 +0,0 @@
|
||||
import { promises as fs } from "fs";
|
||||
import path from "path";
|
||||
|
||||
interface ChangelogEntry {
|
||||
version: string;
|
||||
date: string;
|
||||
description?: string;
|
||||
image?: string;
|
||||
changes: {
|
||||
Added?: string[];
|
||||
Improved?: string[];
|
||||
Fixed?: string[];
|
||||
Deprecated?: string[];
|
||||
Removed?: string[];
|
||||
};
|
||||
}
|
||||
|
||||
export async function getChangelogEntries(): Promise<ChangelogEntry[]> {
|
||||
const filePath = path.join(process.cwd(), "CHANGELOG.md");
|
||||
const content = await fs.readFile(filePath, "utf-8");
|
||||
|
||||
const entries: ChangelogEntry[] = [];
|
||||
let currentEntry: Partial<ChangelogEntry> = {};
|
||||
let currentSection: keyof ChangelogEntry["changes"] | null = null;
|
||||
|
||||
const lines = content.split("\n");
|
||||
|
||||
for (const line of lines) {
|
||||
// Version and date
|
||||
const versionMatch = line.match(/## \[(.+)\] - (\d{4}-\d{2}-\d{2})/);
|
||||
if (versionMatch) {
|
||||
if (Object.keys(currentEntry).length > 0) {
|
||||
entries.push(currentEntry as ChangelogEntry);
|
||||
}
|
||||
currentEntry = {
|
||||
version: versionMatch[1],
|
||||
date: versionMatch[2].split("-").reverse().join("-"),
|
||||
changes: {}
|
||||
};
|
||||
continue;
|
||||
}
|
||||
|
||||
// Description
|
||||
if (line.startsWith("> ")) {
|
||||
currentEntry.description = line.slice(2);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Image
|
||||
const imageMatch = line.match(/!\[.*\]\((.*)\)/);
|
||||
if (imageMatch) {
|
||||
currentEntry.image = imageMatch[1];
|
||||
continue;
|
||||
}
|
||||
|
||||
// Change type
|
||||
const sectionMatch = line.match(/### (Added|Improved|Fixed|Deprecated|Removed)/);
|
||||
if (sectionMatch) {
|
||||
currentSection = sectionMatch[1] as keyof ChangelogEntry["changes"];
|
||||
currentEntry.changes = currentEntry.changes || {};
|
||||
currentEntry.changes[currentSection] = [];
|
||||
continue;
|
||||
}
|
||||
|
||||
// Change item
|
||||
if (line.startsWith("- ") && currentSection && currentEntry.changes) {
|
||||
currentEntry.changes[currentSection]?.push(line.slice(2));
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(currentEntry).length > 0) {
|
||||
entries.push(currentEntry as ChangelogEntry);
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import Accordion from "@/components/markdown/AccordionMdx";
|
||||
import CardGroup from "@/components/markdown/CardGroupMdx";
|
||||
import Kbd from "@/components/markdown/KeyboardMdx";
|
||||
import { Release, Changes } from "@/components/markdown/ReleaseMdx";
|
||||
import { File, Files, Folder } from "@/components/markdown/FileTreeMdx";
|
||||
|
||||
// add custom components
|
||||
const components = {
|
||||
@@ -47,8 +48,13 @@ const components = {
|
||||
Accordion,
|
||||
CardGroup,
|
||||
Kbd,
|
||||
// Release Note Components
|
||||
Release,
|
||||
Changes,
|
||||
// File Tree Components
|
||||
File,
|
||||
Files,
|
||||
Folder,
|
||||
};
|
||||
|
||||
// can be used for other pages like blogs, Guides etc
|
||||
@@ -181,64 +187,3 @@ const postProcess = () => (tree: any) => {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// export type Author = {
|
||||
// avatar?: string;
|
||||
// handle: string;
|
||||
// username: string;
|
||||
// handleUrl: string;
|
||||
// };
|
||||
|
||||
// Blog related types and functions have been removed
|
||||
/*
|
||||
export type BlogMdxFrontmatter = BaseMdxFrontmatter & {
|
||||
date: string;
|
||||
authors: Author[];
|
||||
cover: string;
|
||||
};
|
||||
|
||||
export async function getAllBlogStaticPaths() {
|
||||
try {
|
||||
const blogFolder = path.join(process.cwd(), "/contents/blogs/");
|
||||
const res = await fs.readdir(blogFolder);
|
||||
return res.map((file) => file.split(".")[0]);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export async function getAllBlogs() {
|
||||
const blogFolder = path.join(process.cwd(), "/contents/blogs/");
|
||||
const files = await fs.readdir(blogFolder);
|
||||
const uncheckedRes = await Promise.all(
|
||||
files.map(async (file) => {
|
||||
try {
|
||||
const filepath = path.join(process.cwd(), `/contents/blogs/${file}`);
|
||||
const rawMdx = await fs.readFile(filepath, "utf-8");
|
||||
return {
|
||||
...justGetFrontmatterFromMD<BlogMdxFrontmatter>(rawMdx),
|
||||
slug: file.split(".")[0],
|
||||
};
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
return null;
|
||||
}
|
||||
})
|
||||
);
|
||||
return uncheckedRes.filter((it) => !!it) as (BlogMdxFrontmatter & {
|
||||
slug: string;
|
||||
})[];
|
||||
}
|
||||
|
||||
export async function getBlogForSlug(slug: string) {
|
||||
try {
|
||||
const blogFile = path.join(process.cwd(), "/contents/blogs/", `${slug}.mdx`);
|
||||
const rawMdx = await fs.readFile(blogFile, "utf-8");
|
||||
return await parseMdx<BlogMdxFrontmatter>(rawMdx);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
import docuConfig from "@/docu.json"; // Import JSON file
|
||||
|
||||
export type ContextInfo = {
|
||||
icon: string;
|
||||
description: string;
|
||||
title?: string;
|
||||
};
|
||||
|
||||
export type EachRoute = {
|
||||
title: string;
|
||||
href: string;
|
||||
noLink?: boolean; // Sekarang mendukung boolean
|
||||
noLink?: boolean;
|
||||
context?: ContextInfo;
|
||||
items?: EachRoute[];
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user