Skip to content

Commit

Permalink
Merge pull request #17 from smswithoutborders/develop
Browse files Browse the repository at this point in the history
feat(api): Add draft functionality
  • Loading branch information
PromiseFru authored Apr 29, 2024
2 parents eb64d12 + 2f37336 commit 340e4de
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 26 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ name: Code Quality and Formatting Check
on:
push:
branches:
- main
- staging
pull_request:
branches:
- main
- staging

jobs:
Expand Down
1 change: 1 addition & 0 deletions _posts/smswithoutborders-telemetry-dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ author:
picture: "/anon-avatar.jpeg"
ogImage:
url: "/icon.png"
draft: true
---

At SMSwithoutBorders, we're constantly striving to enhance your secure messaging experience. To accomplish this, we rely on data to comprehend how users interact with our tools. Here's where the SMSwithoutBorders Telemetry Dashboard comes in!
Expand Down
14 changes: 7 additions & 7 deletions _releases/metrics-0-1-0.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ ogImage:

We are excited to announce the release of SMSWithoutBorders Metrics 0.1.0, now available in alpha release! You can access it from the [telemetry page](https://telemetry.smswithoutborders.com).

### **Changelog**

**Added**

- Visuals for reliable and resilient gateway clients.
- Visuals for gateway client reliability tests.

### **Contributors**

A big thank you to the following contributors for their valuable contributions to this release:
Expand All @@ -22,10 +29,3 @@ A big thank you to the following contributors for their valuable contributions t
### **Feedback**

Your feedback is crucial to us! If you encounter any bugs or have suggestions on how we can improve this release, please [let us know](mailto:[email protected]).

### **Changelog**

**Added**

- Visuals for reliable and resilient gateway clients.
- Visuals for gateway client reliability tests.
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ services:
- ${PORT:-80}:80
- ${SSL_PORT:-443}:443
environment:
- PORT=${PORT:-80}
- SSL_PORT=${SSL_PORT:-443}
- SERVER_NAME=${SERVER_NAME:-localhost}
volumes:
- ${SSL_CERTIFICATE_PATH:?err}:/etc/nginx/ssl/cert.pem
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "next",
"build": "next build",
"start": "next start",
"prepare": "husky install"
"prepare": "husky"
},
"dependencies": {
"classnames": "^2.5.1",
Expand Down
29 changes: 15 additions & 14 deletions src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { join } from "path";
const postsDirectory = join(process.cwd(), "_posts");
const releasesDirectory = join(process.cwd(), "_releases");

export function getPostSlugs() {
return fs.readdirSync(postsDirectory);
export function getSlugs(directory: fs.PathLike) {
return fs.readdirSync(directory);
}

export function getPostBySlug(slug: string) {
Expand All @@ -16,6 +16,10 @@ export function getPostBySlug(slug: string) {
const fileContents = fs.readFileSync(fullPath, "utf8");
const { data, content } = matter(fileContents);

if (data.draft === true) {
return null;
}

return { ...data, slug: realSlug, content } as Post;
}

Expand All @@ -25,31 +29,28 @@ export function getReleaseBySlug(slug: string) {
const fileContents = fs.readFileSync(fullPath, "utf8");
const { data, content } = matter(fileContents);

return { ...data, slug: realSlug, content } as Post;
}

export function getReleaseSlugs() {
if (!fs.existsSync(releasesDirectory)) {
console.error(`Directory ${releasesDirectory} does not exist.`);
return [];
if (data.draft === true) {
return null;
}
return fs.readdirSync(releasesDirectory);

return { ...data, slug: realSlug, content } as Post;
}

export function getAllPosts(): Post[] {
const slugs = getPostSlugs();
const slugs = getSlugs(postsDirectory);
const posts = slugs
.map((slug) => getPostBySlug(slug))
// sort posts by date in descending order
.filter((post): post is Post => post !== null)
.sort((post1, post2) => (post1.date > post2.date ? -1 : 1));
return posts;
}

export function getAllReleases(): Post[] {
const slugs = getReleaseSlugs();
const slugs = getSlugs(releasesDirectory);
const releases = slugs
.map((slug) => getReleaseBySlug(slug))
.sort((post1, post2) => (post1.date > post2.date ? -1 : 1));
.filter((release): release is Post => release !== null)
.sort((release1, release2) => (release1.date > release2.date ? -1 : 1));

return releases;
}

0 comments on commit 340e4de

Please sign in to comment.