Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/Release Notes - Added to Home Page under What's New #26

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
21 changes: 14 additions & 7 deletions .astro/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,20 @@ declare module 'astro:content' {
collection: "docs";
data: InferEntrySchema<"docs">
} & { render(): Render[".mdx"] };
"quickstart.mdx": {
id: "quickstart.mdx";
slug: "quickstart";
body: string;
collection: "docs";
data: InferEntrySchema<"docs">
} & { render(): Render[".mdx"] };
"releasenotes.mdx": {
id: "releasenotes.mdx";
slug: "releasenotes";
body: string;
collection: "docs";
data: InferEntrySchema<"docs">
} & { render(): Render[".mdx"] };
"settings/connection.mdx": {
id: "settings/connection.mdx";
slug: "settings/connection";
Expand Down Expand Up @@ -353,13 +367,6 @@ declare module 'astro:content' {
collection: "docs";
data: InferEntrySchema<"docs">
} & { render(): Render[".mdx"] };
"tips/quickstart.mdx": {
id: "tips/quickstart.mdx";
slug: "tips/quickstart";
body: string;
collection: "docs";
data: InferEntrySchema<"docs">
} & { render(): Render[".mdx"] };
"tips/setup.mdx": {
id: "tips/setup.mdx";
slug: "tips/setup";
Expand Down
2 changes: 2 additions & 0 deletions .env example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Github Token with `public_repo` scope https://github.com/settings/tokens
API_GITHUB_TOKEN=
2 changes: 2 additions & 0 deletions .github/workflows/astro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ jobs:
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
working-directory: ${{ env.BUILD_PATH }}
- name: Build with Astro
env:
API_GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }}
run: |
${{ steps.detect-package-manager.outputs.runner }} astro build \
--site "${{ steps.pages.outputs.origin }}" \
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
.vscode-test/
*.vsix
dist
.DS_Store
.DS_Store
.env
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/check": "^0.5.5",
"@astrojs/starlight": "^0.19.1",
"astro": "^4.3.5",
"dotenv": "^16.4.5",
"marked": "^12.0.0",
"sharp": "^0.32.5",
"@astrojs/check": "^0.5.5",
"typescript": "^5.3.3"
}
}
}
1 change: 1 addition & 0 deletions src/assets/github-mark-black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/github-mark-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions src/components/ReleaseNotes.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
import { marked } from 'marked';
import { fetchFromGitHub } from './githubAPI';

// Fetch the releases server-side
const releases = await fetchFromGitHub('releases');

// Check if releases is defined before trying to parse
let releasesBodyHtml = [];
if (releases) {
releasesBodyHtml = releases.map((release : any) => {
return {
name: release.name,
body: marked(release.body)
};
});
}
---

{releasesBodyHtml.map((release: any) => (
<div>
<h2>{release.name}</h2>
<div set:html={release.body}></div>
<br />
<hr />
<br />
</div>
))}
14 changes: 14 additions & 0 deletions src/components/ReleaseVersion.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
import { fetchFromGitHub } from './githubAPI';

// Fetch the latest release server-side
const release = await fetchFromGitHub('releases/latest');

// Extract the version number
let version = '';
if (release) {
version = release.tag_name;
}
---

{version}
45 changes: 45 additions & 0 deletions src/components/githubAPI.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import dotenv from 'dotenv';
dotenv.config();

// GitHub repository details
const baseURL = 'https://api.github.com/repos';
const owner = 'codefori';
const repo = 'vscode-ibmi';
const token = process.env.API_GITHUB_TOKEN || '';

/**
* Fetch data from GitHub API.
*
* @param {string} endpoint - The API endpoint to fetch from.
* @param {number} limit - The maximum number of items to fetch (default is 5).
* @return {Promise<any>} The data from the API, or null if an error occurred.
*/
async function fetchFromGitHub(endpoint: string, limit: number = 5) {

if (!token) {
console.error('No GitHub token provided. Setup .env file.');
return null;
}

const url = new URL(`${baseURL}/${owner}/${repo}/${endpoint}`);
url.searchParams.append('per_page', String(limit));

const headers = {
'Authorization': `token ${token}`,
'Accept': 'application/vnd.github.v3+json'
};
try {
const response = await fetch(url.toString(), { headers });
if (!response.ok) {
console.error(`HTTP error! status: ${response.status}`);
return null;
}
const data = await response.json();
return data;
} catch (error) {
console.error(`Failed to fetch from GitHub: ${error}`);
return null;
}
}

export { fetchFromGitHub };
6 changes: 5 additions & 1 deletion src/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ title: Code for IBM i
---

import { CardGrid, Card, Icon } from '@astrojs/starlight/components';
import ReleaseVersion from '../../components/ReleaseVersion.astro';

## IBM i development extension for VS Code
## IBM i development extension for VS Code

Maintain and compile your RPGLE, CL, COBOL, C/CPP on the IBM i right from Visual Studio Code.

![intro_01.png](../../assets/intro_01.png)

### What's New in Code for IBM i <ReleaseVersion />
See our [Release Notes](./releasenotes/) for the latest updates and features.

## Requirements

- SSH Daemon must be started on IBM i.
Expand Down
15 changes: 15 additions & 0 deletions src/content/docs/releasenotes.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: Release Notes
tableOfContents: false
hero:
image:
dark: ../../assets/github-mark-white.svg
light: ../../assets/github-mark-black.svg
---

import ReleaseNotes from '../../components/ReleaseNotes.astro';
import { LinkCard } from '@astrojs/starlight/components';

<ReleaseNotes />

<LinkCard title="Explore More Releases on Github" href="https://github.com/codefori/vscode-ibmi/releases" />