Skip to content

Commit

Permalink
docs(core): cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo committed Apr 15, 2024
1 parent 9aeaf85 commit b522dd7
Show file tree
Hide file tree
Showing 29 changed files with 518 additions and 276 deletions.
35 changes: 35 additions & 0 deletions .eslintrc.base.json
@@ -0,0 +1,35 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
}
]
}
@@ -1,16 +1,15 @@
---
title: 'Design Article 3'
title: 'Placeholder'
description: ''
authors:
- 'Juri Strumpflohner'
published: '2019-01-01'
updated: '2019-01-01'
cover_image: '/documentation/blog/images/thumbnail-nx15_7.png'
tags:
- design
- Nx
reposts:
- https://dev.to/nx/nx-conf-2023-recap-53ep
pinned: true
---

Bla bla some intro text.
Expand Down
@@ -1,11 +1,9 @@
---
title: 'Design Article 4'
title: 'Placeholder'
description: ''
authors:
- 'Juri Strumpflohner'
published: '2019-01-01'
updated: '2019-01-01'
cover_image: '/documentation/blog/images/thumbnail-own-trpc.png'
cover_image: '/documentation/blog/images/thumbnail-nx15_7.png'
tags:
- design
- Nx
Expand Down
@@ -1,11 +1,9 @@
---
title: 'Design Article 5'
title: 'Placeholder'
description: ''
authors:
- 'Juri Strumpflohner'
published: '2019-01-01'
updated: '2019-01-01'
cover_image: '/documentation/blog/images/thumbnail-build-own-cli.png'
cover_image: '/documentation/blog/images/thumbnail-nx15_7.png'
tags:
- design
- Nx
Expand Down
@@ -1,12 +1,9 @@
---
title: 'Design Article 2x'
title: 'Placeholder'
description: ''
authors:
- 'Juri Strumpflohner'
published: '2019-01-01'
updated: '2019-01-01'
cover_image: '/documentation/blog/images/thumbnail-nx-console-nx-cloud.png'
slug: custom-slug
cover_image: '/documentation/blog/images/thumbnail-nx15_7.png'
tags:
- design
- Nx
Expand Down
24 changes: 24 additions & 0 deletions docs/blog/2023-02-01-placeholder.md
@@ -0,0 +1,24 @@
---
title: 'Placeholder'
description: ''
authors:
- 'Juri Strumpflohner'
cover_image: '/documentation/blog/images/thumbnail-nx15_7.png'
tags:
- design
- Nx
reposts:
- https://dev.to/nx/nx-conf-2023-recap-53ep
---

Bla bla some intro text.

## Code Example

```ts
const foo = 'bar';

function someFn() {
return foo;
}
```
24 changes: 24 additions & 0 deletions docs/blog/2023-03-01-placeholder.md
@@ -0,0 +1,24 @@
---
title: 'Placeholder'
description: ''
authors:
- 'Juri Strumpflohner'
cover_image: '/documentation/blog/images/thumbnail-nx15_7.png'
tags:
- design
- Nx
reposts:
- https://dev.to/nx/nx-conf-2023-recap-53ep
---

Bla bla some intro text.

## Code Example

```ts
const foo = 'bar';

function someFn() {
return foo;
}
```
24 changes: 24 additions & 0 deletions docs/blog/2023-04-01-placeholder.md
@@ -0,0 +1,24 @@
---
title: 'Placeholder'
description: ''
authors:
- 'Juri Strumpflohner'
cover_image: '/documentation/blog/images/thumbnail-nx15_7.png'
tags:
- design
- Nx
reposts:
- https://dev.to/nx/nx-conf-2023-recap-53ep
---

Bla bla some intro text.

## Code Example

```ts
const foo = 'bar';

function someFn() {
return foo;
}
```
24 changes: 24 additions & 0 deletions docs/blog/2023-09-01-placeholder.md
@@ -0,0 +1,24 @@
---
title: 'Placeholder'
description: ''
authors:
- 'Juri Strumpflohner'
cover_image: '/documentation/blog/images/thumbnail-nx15_7.png'
tags:
- design
- Nx
reposts:
- https://dev.to/nx/nx-conf-2023-recap-53ep
---

Bla bla some intro text.

## Code Example

```ts
const foo = 'bar';

function someFn() {
return foo;
}
```
Expand Up @@ -4,13 +4,14 @@ description: ''
authors:
- 'Juri Strumpflohner'
- 'Zack DeRose'
published: '2023-10-20'
date: '2023-10-20'
cover_image: '/documentation/blog/images/thumbnail-nx-conf-recap.png'
tags:
- design
- Nx
reposts:
- https://dev.to/nx/nx-conf-2023-recap-53ep
pinned: true
---

We're excited to announce the release of Nx version 17! In this article, we'll cover the main things you need to know to get the most of Nx 17!
Expand Down
83 changes: 36 additions & 47 deletions nx-dev/data-access-documents/src/lib/blog.api.ts
@@ -1,24 +1,8 @@
import { readFileSync, readdirSync } from 'fs';
import { join, basename } from 'path';
import { extractFrontmatter } from '@nx/nx-dev/ui-markdoc';

export type BlogPostFrontmatter = {
title: string;
description: string;
authors: string[];
published: string;
updated?: string;
cover_image: string;
tags: string[];
reposts: string[];
};

export type BlogPostDataEntry = {
content: string;
frontmatter: BlogPostFrontmatter;
filePath: string;
slug: string;
};
import { sortPosts } from './blog.util';
import { BlogPostDataEntry } from './blog.model';

const calculateSlug = (filePath: string, frontmatter: any) => {
const baseName = basename(filePath, '.md');
Expand All @@ -41,38 +25,43 @@ export class BlogApi {
}

getBlogPosts(): BlogPostDataEntry[] {
const files = readdirSync(this.options.blogRoot);
const files: string[] = readdirSync(this.options.blogRoot);
const allPosts: BlogPostDataEntry[] = [];

return files
.map((file) => {
const filePath = join(this.options.blogRoot, file);
for (const file of files) {
const filePath = join(this.options.blogRoot, file);
// filter out directories (e.g. images)
if (!filePath.endsWith('.md')) continue;

// filter out directories (e.g. images etc)
if (!filePath.endsWith('.md')) {
return null;
}

const content = readFileSync(filePath, 'utf8');
const content = readFileSync(filePath, 'utf8');
const frontmatter = extractFrontmatter(content);
const slug = calculateSlug(filePath, frontmatter);
const post = {
content,
frontmatter: {
title: frontmatter.title,
description: frontmatter.description,
authors: frontmatter.authors,
date: frontmatter.date ?? this.parseDateFromFilename(file),
cover_image: frontmatter.cover_image ?? null,
tags: frontmatter.tags,
reposts: frontmatter.reposts,
},
filePath,
slug,
};
allPosts.push(post);
}

const frontmatter = extractFrontmatter(content);
const slug = calculateSlug(filePath, frontmatter);
return sortPosts(allPosts);
}

return {
content,
frontmatter: {
title: frontmatter.title,
description: frontmatter.description,
authors: frontmatter.authors,
published: frontmatter.published,
updated: frontmatter.updated ?? null,
cover_image: frontmatter.cover_image ?? null,
tags: frontmatter.tags,
reposts: frontmatter.reposts,
},
filePath,
slug,
};
})
.filter((x) => !!x);
private parseDateFromFilename(filename: string): string | null {
const regexp = /^(\d\d\d\d-\d\d-\d\d).+$/;
const match = filename.match(regexp);
if (match) {
return match[1];
}
return null;
}
}
18 changes: 18 additions & 0 deletions nx-dev/data-access-documents/src/lib/blog.model.ts
@@ -0,0 +1,18 @@
export type BlogPostFrontmatter = {
title: string;
description: string;
authors: string[];
date: string;
updated?: string;
cover_image: string;
tags: string[];
reposts: string[];
pinned?: boolean;
};

export type BlogPostDataEntry = {
content: string;
frontmatter: BlogPostFrontmatter;
filePath: string;
slug: string;
};

0 comments on commit b522dd7

Please sign in to comment.