diff --git a/package.json b/package.json index 1addf08..33aa1a5 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@sindresorhus/slugify": "^3.0.0", "cmd-ts": "^0.15.0", "filenamify": "^7.0.1", - "gray-matter": "^4.0.3", + "@11ty/gray-matter": "^2.0.2", "pwd-fs": "^3.5.4" }, "repository": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d520799..9860854 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -261,6 +261,9 @@ importers: .: dependencies: + '@11ty/gray-matter': + specifier: ^2.0.2 + version: 2.0.2 '@clack/prompts': specifier: ^1.4.0 version: 1.4.0 @@ -273,9 +276,6 @@ importers: filenamify: specifier: ^7.0.1 version: 7.0.1 - gray-matter: - specifier: ^4.0.3 - version: 4.0.3 pwd-fs: specifier: ^3.5.4 version: 3.5.4 @@ -304,6 +304,10 @@ importers: packages: + '@11ty/gray-matter@2.0.2': + resolution: {integrity: sha512-+sbmr+BPzzi0z4lFvruKiGQ3D/d5zBssavhH9SzXmWkf7rStnB4gfeEMgz6k1Ac8bpN5NAFCH5GyR3xHk1BGPA==} + engines: {node: '>=11'} + '@babel/generator@8.0.0-rc.5': resolution: {integrity: sha512-nFZPWz3FHIS7y6rMIVoa/WBwjdutfIaRJIBQjzn+t3RnecZoRNlGmGcyR2wb0T/IgSd50Kz/6dG8/LvMCRunjg==} engines: {node: ^22.18.0 || >=24.11.0} @@ -984,10 +988,6 @@ packages: graceful-fs@4.2.11: resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} - gray-matter@4.0.3: - resolution: {integrity: sha512-5v6yZd4JK3eMI3FqqCouswVqwugaA9r4dNZB1wwcmrD02QkV5H0y7XBQW8QwQqEaZY1pM9aqORSORhJRdNK44Q==} - engines: {node: '>=6.0'} - hookable@6.1.1: resolution: {integrity: sha512-U9LYDy1CwhMCnprUfeAZWZGByVbhd54hwepegYTK7Pi5NvqEj63ifz5z+xukznehT7i6NIZRu89Ay1AZmRsLEQ==} @@ -1245,10 +1245,6 @@ packages: resolution: {integrity: sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==} engines: {node: '>=12'} - strip-bom-string@1.0.0: - resolution: {integrity: sha512-uCC2VHvQRYu+lMh4My/sFNmF2klFymLX1wHJeXnbEJERpV/ZsVuonzerjfrGpIGF7LBVa1O7i9kjiWvJiFck8g==} - engines: {node: '>=0.10.0'} - strip-bom@3.0.0: resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} engines: {node: '>=4'} @@ -1337,6 +1333,11 @@ packages: snapshots: + '@11ty/gray-matter@2.0.2': + dependencies: + js-yaml: 4.1.1 + section-matter: 1.0.0 + '@babel/generator@8.0.0-rc.5': dependencies: '@babel/parser': 8.0.0-rc.5 @@ -1978,13 +1979,6 @@ snapshots: graceful-fs@4.2.11: {} - gray-matter@4.0.3: - dependencies: - js-yaml: 3.14.2 - kind-of: 6.0.3 - section-matter: 1.0.0 - strip-bom-string: 1.0.0 - hookable@6.1.1: {} human-id@4.1.3: {} @@ -2191,8 +2185,6 @@ snapshots: dependencies: ansi-regex: 6.2.2 - strip-bom-string@1.0.0: {} - strip-bom@3.0.0: {} term-size@2.2.1: {} diff --git a/src/commands/new.ts b/src/commands/new.ts index a8fa66c..b5a04bb 100644 --- a/src/commands/new.ts +++ b/src/commands/new.ts @@ -3,7 +3,7 @@ import { intro, isCancel, outro, text } from "@clack/prompts"; import slugify from "@sindresorhus/slugify"; import { command, restPositionals, string } from "cmd-ts"; import filenamify from "filenamify"; -import matter from "gray-matter"; +import matter from "@11ty/gray-matter"; import type { Config, Deps } from "../lib/deps"; export function makeNewCommand({ config, pfs }: Deps) { @@ -38,10 +38,7 @@ export function makeNewCommand({ config, pfs }: Deps) { }); } -async function generateFrontmatter( - title: string, - config: Config, -): Promise { +async function generateFrontmatter(title: string, config: Config): Promise { const description = await makeDescription(title); // const now = new Date(); diff --git a/src/commands/publish.ts b/src/commands/publish.ts index c99a6f8..ff8e38a 100644 --- a/src/commands/publish.ts +++ b/src/commands/publish.ts @@ -1,6 +1,6 @@ import { autocomplete, intro, isCancel, outro } from "@clack/prompts"; import { command } from "cmd-ts"; -import matter from "gray-matter"; +import matter from "@11ty/gray-matter"; import { type Post, parseFrontmatter, @@ -17,9 +17,7 @@ export function makePublishCommand({ config, pfs }: Deps) { args: {}, handler: async () => { const posts = await readPosts(pfs, config); - const drafts = posts.filter( - (post) => parseFrontmatter(post)[config.draftKey] === true, - ); + const drafts = posts.filter((post) => parseFrontmatter(post)[config.draftKey] === true); const selected = await getPostsToPublish(drafts, config); for (const draft of selected) { @@ -29,10 +27,7 @@ export function makePublishCommand({ config, pfs }: Deps) { }); } -async function getPostsToPublish( - drafts: Post[], - config: Config, -): Promise { +async function getPostsToPublish(drafts: Post[], config: Config): Promise { const options = postsToOptions(drafts, config); intro("Publishing posts"); @@ -48,10 +43,7 @@ async function getPostsToPublish( outro("Posts undrafted..."); - return selectedValuesToPosts( - Array.isArray(selected) ? selected : [selected], - drafts, - ); + return selectedValuesToPosts(Array.isArray(selected) ? selected : [selected], drafts); } async function updateDraftFrontMatter(draft: Post, deps: Deps) { diff --git a/src/commands/unpublish.ts b/src/commands/unpublish.ts index af62ca6..4ace2a7 100644 --- a/src/commands/unpublish.ts +++ b/src/commands/unpublish.ts @@ -1,12 +1,7 @@ import { autocomplete, intro, isCancel, outro } from "@clack/prompts"; import { command } from "cmd-ts"; -import matter from "gray-matter"; -import { - findPostByFile, - type Post, - postsToOptions, - readPosts, -} from "../lib/commands"; +import matter from "@11ty/gray-matter"; +import { findPostByFile, type Post, postsToOptions, readPosts } from "../lib/commands"; import type { Config, Deps } from "../lib/deps"; export function makeUnPublishCommand({ config, pfs }: Deps) { @@ -24,10 +19,7 @@ export function makeUnPublishCommand({ config, pfs }: Deps) { }); } -async function getPostToUnpub( - posts: Post[], - config: Config, -): Promise { +async function getPostToUnpub(posts: Post[], config: Config): Promise { const options = postsToOptions(posts, config); intro("Unpublish a post"); diff --git a/src/commands/update.ts b/src/commands/update.ts index b7d2b1a..b867278 100644 --- a/src/commands/update.ts +++ b/src/commands/update.ts @@ -1,12 +1,7 @@ import { autocomplete, intro, isCancel, outro } from "@clack/prompts"; import { command } from "cmd-ts"; -import matter from "gray-matter"; -import { - findPostByFile, - type Post, - postsToOptions, - readPosts, -} from "../lib/commands"; +import matter from "@11ty/gray-matter"; +import { findPostByFile, type Post, postsToOptions, readPosts } from "../lib/commands"; import type { Config, Deps } from "../lib/deps"; export function makeUpdateCommand({ config, pfs }: Deps) { @@ -24,10 +19,7 @@ export function makeUpdateCommand({ config, pfs }: Deps) { }); } -async function getPostToUpdate( - posts: Post[], - config: Config, -): Promise { +async function getPostToUpdate(posts: Post[], config: Config): Promise { const options = postsToOptions(posts, config); intro("Update a post"); diff --git a/src/lib/commands.ts b/src/lib/commands.ts index 586e466..1c32d48 100644 --- a/src/lib/commands.ts +++ b/src/lib/commands.ts @@ -1,4 +1,4 @@ -import matter from "gray-matter"; +import matter from "@11ty/gray-matter"; import type { Config, Deps } from "./deps"; export type Post = { @@ -9,10 +9,7 @@ export type Post = { export type Frontmatter = Record; /** Read all files from the blog directory and return them as Post objects */ -export async function readPosts( - pfs: Deps["pfs"], - config: Config, -): Promise { +export async function readPosts(pfs: Deps["pfs"], config: Config): Promise { const files = (await pfs.readdir(config.blogDir)) as string[]; const posts: Post[] = []; @@ -45,17 +42,11 @@ export function postsToOptions(posts: Post[], config: Config) { } /** Take the raw selected values returned by the prompt and return matching Post[] */ -export function selectedValuesToPosts( - selected: string[] | symbol, - posts: Post[], -): Post[] { +export function selectedValuesToPosts(selected: string[] | symbol, posts: Post[]): Post[] { if (typeof selected === "symbol") return []; return posts.filter((p) => selected.includes(p.file)); } -export function findPostByFile( - posts: Post[], - fileName: string, -): Post | undefined { +export function findPostByFile(posts: Post[], fileName: string): Post | undefined { return posts.find((p) => p.file === fileName); } diff --git a/src/lib/tags.ts b/src/lib/tags.ts index 44d719f..af1a687 100644 --- a/src/lib/tags.ts +++ b/src/lib/tags.ts @@ -1,4 +1,4 @@ -import matter from "gray-matter"; +import matter from "@11ty/gray-matter"; import type { Deps } from "./deps"; export type GetAllTagsOptions = { @@ -14,17 +14,12 @@ export type GetAllTagsOptions = { * This implementation uses the PoweredFileSystem API (pfs) for all path resolution and IO * instead of `path.join` so it respects the pfs instance's `pwd` resolution semantics. */ -export async function getAllTags( - deps: Deps, - opts: GetAllTagsOptions = {}, -): Promise { +export async function getAllTags(deps: Deps, opts: GetAllTagsOptions = {}): Promise { const { pfs, config } = deps; const { concurrency = 8, lowerCase = true, sort = true } = opts; const files = (await pfs.readdir(config.blogDir)) as string[]; - const mdFiles = files.filter( - (f) => f.endsWith(".md") || f.endsWith(".markdown"), - ); + const mdFiles = files.filter((f) => f.endsWith(".md") || f.endsWith(".markdown")); // split into batches of size `concurrency` const batches: string[][] = [];