-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
136 changed files
with
6,782 additions
and
777 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
extends: ['next/core-web-vitals', 'prettier'], | ||
ignorePatterns: ['**/.next/**', '**/node_modules/**'], | ||
root: true, | ||
settings: { | ||
next: { | ||
rootDir: ['basics/*/', 'dashboard/*/', 'seo/'], | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: 'github-actions' | ||
directory: '/' | ||
schedule: | ||
interval: 'weekly' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: test | ||
on: pull_request | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cancel running workflows | ||
uses: styfle/cancel-workflow-action@0.11.0 | ||
with: | ||
access_token: ${{ github.token }} | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v2 | ||
- name: Set node version | ||
uses: actions/setup-node@v3 | ||
with: | ||
cache: 'pnpm' | ||
node-version-file: '.nvmrc' | ||
- name: Cache node_modules | ||
id: node-modules-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: '**/node_modules' | ||
key: node-modules-cache-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
- name: Install dependencies | ||
if: steps.node-modules-cache.outputs.cache-hit != 'true' | ||
run: pnpm install | ||
- name: Run tests | ||
run: pnpm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.log | ||
.DS_Store | ||
node_modules |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
**/.next | ||
**/node_modules | ||
**/package-lock.json | ||
**/pnpm-lock.yaml |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
This is a starter template for [Learn Next.js](https://nextjs.org/learn). | ||
This is a starter template for [Learn Next.js](https://nextjs.org/learn). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { parseISO, format } from 'date-fns' | ||
import { parseISO, format } from 'date-fns'; | ||
|
||
export default function Date({ dateString }) { | ||
const date = parseISO(dateString) | ||
return <time dateTime={dateString}>{format(date, 'LLLL d, yyyy')}</time> | ||
const date = parseISO(dateString); | ||
return <time dateTime={dateString}>{format(date, 'LLLL d, yyyy')}</time>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,69 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
import matter from 'gray-matter' | ||
import { remark } from 'remark' | ||
import html from 'remark-html' | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import matter from 'gray-matter'; | ||
import { remark } from 'remark'; | ||
import html from 'remark-html'; | ||
|
||
const postsDirectory = path.join(process.cwd(), 'posts') | ||
const postsDirectory = path.join(process.cwd(), 'posts'); | ||
|
||
export function getSortedPostsData() { | ||
// Get file names under /posts | ||
const fileNames = fs.readdirSync(postsDirectory) | ||
const allPostsData = fileNames.map(fileName => { | ||
const fileNames = fs.readdirSync(postsDirectory); | ||
const allPostsData = fileNames.map((fileName) => { | ||
// Remove ".md" from file name to get id | ||
const id = fileName.replace(/\.md$/, '') | ||
const id = fileName.replace(/\.md$/, ''); | ||
|
||
// Read markdown file as string | ||
const fullPath = path.join(postsDirectory, fileName) | ||
const fileContents = fs.readFileSync(fullPath, 'utf8') | ||
const fullPath = path.join(postsDirectory, fileName); | ||
const fileContents = fs.readFileSync(fullPath, 'utf8'); | ||
|
||
// Use gray-matter to parse the post metadata section | ||
const matterResult = matter(fileContents) | ||
const matterResult = matter(fileContents); | ||
|
||
// Combine the data with the id | ||
return { | ||
id, | ||
...matterResult.data | ||
} | ||
}) | ||
...matterResult.data, | ||
}; | ||
}); | ||
// Sort posts by date | ||
return allPostsData.sort((a, b) => { | ||
if (a.date < b.date) { | ||
return 1 | ||
return 1; | ||
} else { | ||
return -1 | ||
return -1; | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
export function getAllPostIds() { | ||
const fileNames = fs.readdirSync(postsDirectory) | ||
return fileNames.map(fileName => { | ||
const fileNames = fs.readdirSync(postsDirectory); | ||
return fileNames.map((fileName) => { | ||
return { | ||
params: { | ||
id: fileName.replace(/\.md$/, '') | ||
} | ||
} | ||
}) | ||
id: fileName.replace(/\.md$/, ''), | ||
}, | ||
}; | ||
}); | ||
} | ||
|
||
export async function getPostData(id) { | ||
const fullPath = path.join(postsDirectory, `${id}.md`) | ||
const fileContents = fs.readFileSync(fullPath, 'utf8') | ||
const fullPath = path.join(postsDirectory, `${id}.md`); | ||
const fileContents = fs.readFileSync(fullPath, 'utf8'); | ||
|
||
// Use gray-matter to parse the post metadata section | ||
const matterResult = matter(fileContents) | ||
const matterResult = matter(fileContents); | ||
|
||
// Use remark to convert markdown into HTML string | ||
const processedContent = await remark() | ||
.use(html) | ||
.process(matterResult.content) | ||
const contentHtml = processedContent.toString() | ||
.process(matterResult.content); | ||
const contentHtml = processedContent.toString(); | ||
|
||
// Combine the data with the id and contentHtml | ||
return { | ||
id, | ||
contentHtml, | ||
...matterResult.data | ||
} | ||
...matterResult.data, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import '../styles/global.css' | ||
import '../styles/global.css'; | ||
|
||
export default function App({ Component, pageProps }) { | ||
return <Component {...pageProps} /> | ||
return <Component {...pageProps} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
This is a starter template for [Learn Next.js](https://nextjs.org/learn). | ||
This is a starter template for [Learn Next.js](https://nextjs.org/learn). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
{ | ||
"private": true, | ||
"engines": { | ||
"node": ">=18" | ||
}, | ||
"scripts": { | ||
"dev": "next dev", | ||
"build": "next build", | ||
"dev": "next dev", | ||
"start": "next start" | ||
}, | ||
"dependencies": { | ||
"next": "latest", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0" | ||
}, | ||
"engines": { | ||
"node": ">=18" | ||
} | ||
} |
Oops, something went wrong.