Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
feat: simplify and add changelog (#199)
Browse files Browse the repository at this point in the history
* feat: wip cortex changelog

* chore: update chagelog

* chore: finished add changelog page

* chore: remove log

* chore: get changelog manualy from directory

* chore: create multi-instance docs for changelog

* chore: update template changelog

* chore: copy nits
  • Loading branch information
urmauur authored Sep 30, 2024
1 parent ae25ff5 commit 96e4574
Show file tree
Hide file tree
Showing 18 changed files with 1,243 additions and 52 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.mdx
*.hbs
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,17 @@ $ GIT_USER=<Your GitHub username> yarn deploy
```

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.

## Changelog Generator

To generate a changelog post, run:

```bash
yarn create:changelog
```

- **Title & Slug**: Generate changelog post files with a title and a slug.
- **Description**: Add a description for the changelog post.
- **Version**: Add a version for the changelog post.

The pages will be generated in `changelog/${slug}`. You can start writing your changelog post here.
24 changes: 24 additions & 0 deletions changelog/cortex-cpp-version-to-log.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
hide:
- title
title: "v0.5.0 cortex-cpp version to log"
version: 0.5.0
date: 2024-06-29
ogImage: "/img/changelog/social-card.jpg"
slug: "cortex-cpp-version-to-log"
description: ''
---

import ChangelogHeader from "@site/src/components/ChangelogHeader"

<ChangelogHeader slug="cortex-cpp-version-to-log" />

### Highlights 🎉
- Add cortex-cpp version to log
- Cortex cli as client - communicate with API server via cortexjs
- Unsupported platform engine status
- Update default api server config
- Transform anthropic response
- Github hotsted to macos selfhosted
- Release and fix winget
- Handle multi download model, uninstall script
79 changes: 59 additions & 20 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import type * as Preset from "@docusaurus/preset-classic";
import type { ScalarOptions } from "@scalar/docusaurus";
import { downloadFile, listModels, listFiles } from "@huggingface/hub";
import { remarkCodeHike } from "@code-hike/mdx";
import fs from "fs";
import path from "path";
import matter from "gray-matter";

const date = new Date();

Expand Down Expand Up @@ -45,9 +48,7 @@ function generateDates(startDate: string, numberOfDays: number): string[] {
return dates;
}

// disbale this one for avoid date 19,20 may
const dateArray = generateDates(formattedDate, 30);
// const dateArray = generateDates("06-21-2024", 30);

const config: Config = {
title: "Cortex",
Expand All @@ -58,6 +59,14 @@ const config: Config = {
staticDirectories: ["static"],

plugins: [
[
"@docusaurus/plugin-content-docs",
{
id: "changelog",
path: "changelog",
routeBasePath: "changelog",
},
],
"docusaurus-plugin-sass",
async function myPlugin(context, options) {
return {
Expand All @@ -70,6 +79,7 @@ const config: Config = {
},
};
},

async function modelsPagesGenPlugin(context, options) {
return {
name: "list-models",
Expand Down Expand Up @@ -162,26 +172,62 @@ const config: Config = {
},
};
},

async function getChangelogList(context, options) {
return {
name: "changelog-list",
async contentLoaded({ content, actions }) {
const { setGlobalData } = actions;

let changelog = [];

const changelogDir = path.resolve(__dirname, "changelog");
const files = fs.readdirSync(changelogDir);

// Loop through all .mdx files in the changelog directory
files.forEach(async (file) => {
if (file.endsWith(".mdx")) {
const filePath = path.join(changelogDir, file);
const fileContent = fs.readFileSync(filePath, "utf-8");

const { data, content } = matter(fileContent);

changelog.push({
frontmatter: data, // Frontmatter metadata (e.g., title, date)
body: content, // The actual MDX content
});
}
});
changelog.sort(
(a, b) =>
new Date(b.frontmatter.date).getTime() -
new Date(a.frontmatter.date).getTime()
);
setGlobalData(changelog);
},
};
},

async function getRepoInfo(context, options) {
return {
name: "repo-info",
async contentLoaded({ content, actions }) {
const { setGlobalData } = actions;
const fetchRepoInfo = await fetch(
"https://api.github.com/repos/janhq/cortex"
"https://api.github.com/repos/janhq/cortex.cpp"
);
const repoInfo = await fetchRepoInfo.json();
setGlobalData(repoInfo);
},
};
},
async function getRepoInfo(context, options) {
async function getRepoLatestReleaseInfo(context, options) {
return {
name: "latest-release",
async contentLoaded({ content, actions }) {
const { setGlobalData } = actions;
const fetchLatestRelease = await fetch(
"https://api.github.com/repos/janhq/cortex/releases/latest"
"https://api.github.com/repos/janhq/cortex.cpp/releases/latest"
);
const latestRelease = await fetchLatestRelease.json();
setGlobalData(latestRelease);
Expand Down Expand Up @@ -229,7 +275,7 @@ const config: Config = {
route: "/api-reference",
configuration: {
spec: {
url: "https://raw.githubusercontent.com/janhq/cortex-web/main/static/openapi/jan.json",
url: "https://raw.githubusercontent.com/janhq/cortex.so/main/static/openapi/jan.json",
},
hideModels: true,
},
Expand Down Expand Up @@ -282,10 +328,6 @@ const config: Config = {
[
"classic",
{
// gtag: {
// trackingID: process.env.GTM_ID,
// },

docs: {
beforeDefaultRemarkPlugins: [
[
Expand All @@ -300,7 +342,7 @@ const config: Config = {
sidebarPath: "./sidebars.ts",
// Please change this to your repo.
// Remove this to remove the "edit this page" links.
editUrl: "https://github.com/janhq/cortex-web/tree/main/",
editUrl: "https://github.com/janhq/cortex.so/tree/main/",
},
sitemap: {
changefreq: "daily",
Expand Down Expand Up @@ -366,23 +408,19 @@ const config: Config = {
width: 116,
},
items: [
{ to: "/models", label: "Models", position: "left" },
{ to: "/changelog", label: "Changelog", position: "right" },
{
type: "doc",
position: "left",
position: "right",
docId: "overview",
label: "Docs",
},
{
to: "/api-reference",
label: "API Reference",
position: "left",
position: "right",
},
// { to: "/docs/cli", label: "CLI", position: "left" },
// {
// type: "custom-productMegaMenu",
// position: "left",
// },
{ to: "/models", label: "Models", position: "left" },
{
type: "search",
position: "right",
Expand All @@ -405,14 +443,15 @@ const config: Config = {
{ to: "/docs/cli", label: "CLI" },
{ href: "/api-reference", label: "API Reference" },
{ to: "/models", label: "Models" },
{ to: "/changelog", label: "Changelog" },
],
},
{
title: "Community",
items: [
{
label: "Github",
href: "https://github.com/janhq/cortex",
href: "https://github.com/janhq/cortex.cpp",
},
{
label: "Discord",
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
"create:changelog": "plop create-changelog",
"typecheck": "tsc"
},
"dependencies": {
Expand All @@ -30,6 +31,8 @@
"@radix-ui/react-tooltip": "^1.0.7",
"@scalar/docusaurus": "^0.3.5",
"autoprefixer": "^10.4.19",
"chalk": "^5.3.0",
"chokidar": "^3.6.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"date-fns": "^3.6.0",
Expand All @@ -39,6 +42,9 @@
"highlight.js": "^11.9.0",
"lucide-react": "^0.395.0",
"markdown-it": "^14.1.0",
"markdown-it-link-attributes": "^4.0.1",
"plop": "^4.0.1",
"plop-helper-date": "^1.0.0",
"postcss": "^8.4.38",
"prism-react-renderer": "^2.3.0",
"react": "^18.0.0",
Expand Down
91 changes: 91 additions & 0 deletions plopfile.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import chalk from "chalk";

const capitalize = (str) => {
return str.charAt(0).toUpperCase() + str.slice(1);
};

const camelCase = (str) => {
return str.replace(/[-_](\w)/g, (_, c) => c.toUpperCase());
};

/**
* @param {import("plop").NodePlopAPI} plop
*/
export default async function (plop) {
plop.setHelper("capitalize", (text) => {
return capitalize(camelCase(text));
});

plop.load("plop-helper-date");

plop.setGenerator("create-changelog", {
description: "Generates a changelog",
prompts: [
{
type: "input",
name: "title",
message: "Enter the title of the changelog post:",
validate: (input) => (input ? true : "Title is required."),
},
{
type: "input",
name: "slug",
message: (answers) =>
`Enter the slug for the changelog post (suggested: ${generateSlug(
answers.title
)})`,
default: (answers) => generateSlug(answers.title),
validate: (input) =>
input && /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(input)
? true
: "Please enter a valid slug (lowercase letters, numbers, and hyphens only).",
},
{
type: "input",
name: "version",
message: "Enter the version of the changelog post:",
validate: (input) => (input ? true : "Title is required."),
},
{
type: "input",
name: "description",
message: "Enter the description of the changelog post:",
validate: (input) => (input ? true : "Description is required."),
},
],

actions(answers) {
const actions = [];
if (!answers) return actions;
const { version, title, description, slug } = answers;

actions.push({
type: "addMany",
templateFiles: "templates/**",
destination: `./changelog`,
globOptions: { dot: true },
data: { title, description, version },
abortOnFail: true,
});

console.log(chalk.green(`Your changelog post is created!`));
console.log(chalk.green(`You can modify under /changelog/${slug}`));
console.log(
chalk.cyan(
`You can view it at: http://localhost:3000/changelog/${slug}`
)
);

return actions;
},
});

function generateSlug(title) {
return title
? title
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-+|-+$/g, "")
: "";
}
}
21 changes: 21 additions & 0 deletions src/components/Announcement/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from "react";

const Announcement = () => {
return (
<div className="inline-flex items-center justify-center alert px-4 py-3 rounded-xl mx-auto bg-indigo-500 border border-solid border-indigo-800">
{/* Please change this when cortex stable we can use from latest release endpoint */}
<div className="flex items-center gap-2">
<span>🚧</span>
<p className="mb-0 text-neutral-100 font-medium">
Cortex.cpp v1.0 is coming soon.
<a href="/docs" className="no-underline hover:no-underline">
{" "}
Read more
</a>
</p>
</div>
</div>
);
};

export default Announcement;
Loading

0 comments on commit 96e4574

Please sign in to comment.