From 2a887440470208002a90693dc743a7247f5add6b Mon Sep 17 00:00:00 2001 From: Ayo Ayco Date: Sat, 4 Jan 2025 23:08:11 +0100 Subject: [PATCH] feat: new script for preparing a now page --- commands/md-to-html.ts | 14 ++ commands/now-template | 69 ++++++ commands/prep-now.ts | 65 ++++++ package.json | 14 +- pnpm-lock.yaml | 201 +++++++++--------- src/constants/now.json | 7 + src/constants/now.md | 1 + src/constants/now.ts | 9 - src/pages/index.astro | 4 +- src/pages/now.astro | 65 ++---- src/pages/now/and-then/posts/2024-12-25.astro | 69 ++++++ 11 files changed, 356 insertions(+), 162 deletions(-) create mode 100644 commands/md-to-html.ts create mode 100644 commands/now-template create mode 100644 commands/prep-now.ts create mode 100644 src/constants/now.json create mode 100644 src/constants/now.md delete mode 100644 src/constants/now.ts create mode 100644 src/pages/now/and-then/posts/2024-12-25.astro diff --git a/commands/md-to-html.ts b/commands/md-to-html.ts new file mode 100644 index 0000000..8d53935 --- /dev/null +++ b/commands/md-to-html.ts @@ -0,0 +1,14 @@ +import rehypeStringify from 'rehype-stringify' +import remarkParse from 'remark-parse' +import remarkRehype from 'remark-rehype' +import { unified } from 'unified' + +export async function mdToHTML(md: string): Promise { + const file = await unified() + .use(remarkParse) + .use(remarkRehype) + .use(rehypeStringify) + .process(md) + + return String(file) +} diff --git a/commands/now-template b/commands/now-template new file mode 100644 index 0000000..10c1591 --- /dev/null +++ b/commands/now-template @@ -0,0 +1,69 @@ +--- +import Layout from '../../../../layouts/Layout.astro' +import Footer from '../../../../components/Footer.astro' + +const title = `__title__` +const description = `__description__` +const publishedOn = `__publishedOn__` +const publishDate = `__publishDate__` +const publishState = `__publishState__` +const content = `__content__` +--- + + +
+

{title}

+

+ + Published on + + {publishState} + +

+ + + +
+
+
+ + diff --git a/commands/prep-now.ts b/commands/prep-now.ts new file mode 100644 index 0000000..98e38ce --- /dev/null +++ b/commands/prep-now.ts @@ -0,0 +1,65 @@ +import { fileURLToPath } from 'node:url' +import { readFileSync, writeFileSync } from 'node:fs' +import { consola } from 'consola' +import { colorize } from 'consola/utils' +import { dirname, resolve } from 'pathe' +import { mdToHTML } from './md-to-html.ts' +import now from '../src/constants/now.json' + +export default async function newNow(): Promise { + consola.box('Preparing for a new Now page!') + const datetime = now.publishDate + const postFileName = `${datetime}.astro` + consola.start(`Copying current now page to ${colorize('blue', postFileName)}`) + + try { + const __filename = fileURLToPath(import.meta.url) + const __dirname = dirname(__filename) + const templateFilePath = resolve(__dirname, './now-template') + const templateContent = readFileSync(templateFilePath, 'utf-8') + + const nowMdPath = resolve(__dirname, '../src/constants/now.md') + const nowContent = readFileSync(nowMdPath, 'utf-8') + const nowHtml = await mdToHTML(nowContent) + + const nowAstro = templateContent + .replace('__title__', now.title) + .replace('__description__', now.description) + .replace('__publishedOn__', now.publishedOn) + .replace('__publishDate__', now.publishDate) + .replace('__publishState__', now.publishState) + .replace('__content__', nowHtml) + + const newPostPath = resolve( + __dirname, + '../src/pages/now/and-then/posts/', + postFileName + ) + writeFileSync(newPostPath, nowAstro) + + /** + * clear now.md + */ + // consola.start('Clearing now.md file...') + // writeFileSync(nowMdPath, '') + // consola.success('now.md cleared') + + /** + * clear now.ts + */ + consola.start('Clearing now.json file...') + const newNowObj = Object.keys(now).reduce( + (acc, key) => ({ ...acc, [key]: '' }), + now + ) // Object.assign({}, now) + newNowObj.publishDate = new Date().toISOString().split('T')[0] ?? '' + const nowJsonPath = resolve(__dirname, '../src/constants/now.json') + writeFileSync(nowJsonPath, JSON.stringify(newNowObj, null, '\t')) + + consola.success('You may now update your Now content and props.\n') + } catch (err) { + consola.fail('Failed to create a new post from Now') + consola.error(err) + } +} +newNow() diff --git a/package.json b/package.json index a009a66..065808c 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "build:preview": "astro build && astro preview", "deploy": "astro build && scp -r dist ayo@ayco.io:~/ayco.io-flask/", "copy:dist": "astro build && cp -R dist ../ayco.io-flask/", - "prepare": "husky && husky install" + "prepare": "husky && husky install", + "prep:now": "npx jiti ./commands/prep-now.js" }, "devDependencies": { "@astro-reactive/form": "^0.10.0", @@ -29,16 +30,22 @@ "astro-eslint-parser": "^1.1.0", "astro-github-stats": "^0.7.1", "astro-iconify": "^1.2.0", + "consola": "^3.3.3", "eslint": "^9.17.0", "eslint-plugin-astro": "^1.3.1", "eslint-plugin-jsx-a11y": "^6.10.2", "globals": "^15.14.0", "husky": "^9.1.7", + "jiti": "^2.4.2", "lint-staged": "^15.3.0", "prettier": "^3.4.2", "prettier-plugin-astro": "^0.14.1", + "rehype-stringify": "^10.0.1", + "remark-parse": "^11.0.0", + "remark-rehype": "^11.1.1", "tslib": "^2.8.1", - "typescript-eslint": "^8.18.2" + "typescript-eslint": "^8.18.2", + "unified": "^11.0.5" }, "packageManager": "pnpm@9.15.0+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c", "lint-staged": { @@ -49,5 +56,8 @@ "*.json": [ "prettier --write" ] + }, + "dependencies": { + "pathe": "^2.0.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7f03230..3bfc4d1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,13 +7,17 @@ settings: importers: .: + dependencies: + pathe: + specifier: ^2.0.0 + version: 2.0.0 devDependencies: '@astro-reactive/form': specifier: ^0.10.0 - version: 0.10.0(@types/node@22.5.4)(astro@5.0.5(@types/node@22.5.4)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1))(rollup@4.28.1)(typescript@5.6.2) + version: 0.10.0(@types/node@22.5.4)(astro@5.0.5(@types/node@22.5.4)(jiti@2.4.2)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1))(rollup@4.28.1)(typescript@5.6.2) '@astro-reactive/validator': specifier: ^0.5.0 - version: 0.5.0(@types/node@22.5.4)(astro@5.0.5(@types/node@22.5.4)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1))(rollup@4.28.1)(typescript@5.6.2) + version: 0.5.0(@types/node@22.5.4)(astro@5.0.5(@types/node@22.5.4)(jiti@2.4.2)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1))(rollup@4.28.1)(typescript@5.6.2) '@astrojs/sitemap': specifier: ^3.2.1 version: 3.2.1 @@ -22,40 +26,46 @@ importers: version: 0.8.12 '@eslint/compat': specifier: ^1.2.4 - version: 1.2.4(eslint@9.17.0) + version: 1.2.4(eslint@9.17.0(jiti@2.4.2)) '@eslint/js': specifier: ^9.17.0 version: 9.17.0 '@typescript-eslint/parser': specifier: ^8.18.2 - version: 8.18.2(eslint@9.17.0)(typescript@5.6.2) + version: 8.18.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.2) astro: specifier: ^5.0.5 - version: 5.0.5(@types/node@22.5.4)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1) + version: 5.0.5(@types/node@22.5.4)(jiti@2.4.2)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1) astro-eslint-parser: specifier: ^1.1.0 version: 1.1.0(typescript@5.6.2) astro-github-stats: specifier: ^0.7.1 - version: 0.7.1(astro@5.0.5(@types/node@22.5.4)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1)) + version: 0.7.1(astro@5.0.5(@types/node@22.5.4)(jiti@2.4.2)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1)) astro-iconify: specifier: ^1.2.0 version: 1.2.0 + consola: + specifier: ^3.3.3 + version: 3.3.3 eslint: specifier: ^9.17.0 - version: 9.17.0 + version: 9.17.0(jiti@2.4.2) eslint-plugin-astro: specifier: ^1.3.1 - version: 1.3.1(eslint@9.17.0)(typescript@5.6.2) + version: 1.3.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.2) eslint-plugin-jsx-a11y: specifier: ^6.10.2 - version: 6.10.2(eslint@9.17.0) + version: 6.10.2(eslint@9.17.0(jiti@2.4.2)) globals: specifier: ^15.14.0 version: 15.14.0 husky: specifier: ^9.1.7 version: 9.1.7 + jiti: + specifier: ^2.4.2 + version: 2.4.2 lint-staged: specifier: ^15.3.0 version: 15.3.0 @@ -65,12 +75,24 @@ importers: prettier-plugin-astro: specifier: ^0.14.1 version: 0.14.1 + rehype-stringify: + specifier: ^10.0.1 + version: 10.0.1 + remark-parse: + specifier: ^11.0.0 + version: 11.0.0 + remark-rehype: + specifier: ^11.1.1 + version: 11.1.1 tslib: specifier: ^2.8.1 version: 2.8.1 typescript-eslint: specifier: ^8.18.2 - version: 8.18.2(eslint@9.17.0)(typescript@5.6.2) + version: 8.18.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.2) + unified: + specifier: ^11.0.5 + version: 11.0.5 packages: @@ -1523,6 +1545,10 @@ packages: confbox@0.1.8: resolution: {integrity: sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==} + consola@3.3.3: + resolution: {integrity: sha512-Qil5KwghMzlqd51UXM0b6fyaGHtOC22scxrwrz4A2882LyUMwQjnvaedN1HAeXzphspQ6CpHkzMAWxBTUruDLg==} + engines: {node: ^14.18.0 || >=16.10.0} + convert-source-map@2.0.0: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} @@ -2067,9 +2093,6 @@ packages: hast-util-raw@9.0.4: resolution: {integrity: sha512-LHE65TD2YiNsHD3YuXcKPHXPLuYh/gjp12mOfU8jxSrm1f/yJpsb0F/KKljS6U9LJoP0Ux+tCe8iJ2AsPzTdgA==} - hast-util-to-html@9.0.2: - resolution: {integrity: sha512-RP5wNpj5nm1Z8cloDv4Sl4RS8jH5HYa0v93YB6Wb4poEzgMo/dAAL0KcT4974dCjcNG5pkLqTImeFHHCwwfY3g==} - hast-util-to-html@9.0.4: resolution: {integrity: sha512-wxQzXtdbhiwGAUKrnQJXlOPmHnEehzphwkK7aluUPQ+lEc1xefC8pblMgpp2w5ldBTEfveRIrADcrhGIWrlTDA==} @@ -2280,6 +2303,10 @@ packages: isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + jiti@2.4.2: + resolution: {integrity: sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==} + hasBin: true + js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -2750,6 +2777,9 @@ packages: pathe@1.1.2: resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} + pathe@2.0.0: + resolution: {integrity: sha512-G7n4uhtk9qJt2hlD+UFfsIGY854wpF+zs2bUbQ3CQEUTcn7v25LRsrmurOxTo4bJgjE4qkyshd9ldsEuY9M6xg==} + pend@1.2.0: resolution: {integrity: sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==} @@ -2866,9 +2896,6 @@ packages: rehype-raw@7.0.0: resolution: {integrity: sha512-/aE8hCfKlQeA8LmyeyQvQF3eBiLRGNlfBJEvWH7ivp9sBqs7TNqBL5X3v157rM4IFETqDnIOO+z5M/biZbo9Ww==} - rehype-stringify@10.0.0: - resolution: {integrity: sha512-1TX1i048LooI9QoecrXy7nGFFbFSufxVRAfc6Y9YMRAi56l+oB0zP51mLSV312uRuvVLPV1opSlJmslozR1XHQ==} - rehype-stringify@10.0.1: resolution: {integrity: sha512-k9ecfXHmIPuFVI61B9DeLPN0qFHfawM6RsuX48hoqlaKSF61RskNjSm1lI8PhBEM0MRdLxVVm4WmTqJQccH9mA==} @@ -2884,9 +2911,6 @@ packages: remark-parse@11.0.0: resolution: {integrity: sha512-FCxlKLNGknS5ba/1lmpYijMUzX2esxW5xQqjWxw2eHFfS2MSdaHVINFmhjo+qN1WhZhNimq0dZATN9pH0IDrpA==} - remark-rehype@11.1.0: - resolution: {integrity: sha512-z3tJrAs2kIs1AqIIy6pzHmAHlF1hWQ+OdY4/hv+Wxe35EhyLKcajL33iUEn3ScxtFox9nUvRufR/Zre8Q08H/g==} - remark-rehype@11.1.1: resolution: {integrity: sha512-g/osARvjkBXb6Wo0XvAeXQohVta8i84ACbenPpoSsxTOQH/Ae0/RGP4WZgnMH5pMLpsj4FG7OHmcIcXxpza8eQ==} @@ -3554,11 +3578,11 @@ snapshots: - terser - typescript - '@astro-reactive/form@0.10.0(@types/node@22.5.4)(astro@5.0.5(@types/node@22.5.4)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1))(rollup@4.28.1)(typescript@5.6.2)': + '@astro-reactive/form@0.10.0(@types/node@22.5.4)(astro@5.0.5(@types/node@22.5.4)(jiti@2.4.2)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1))(rollup@4.28.1)(typescript@5.6.2)': dependencies: '@astro-reactive/common': 0.3.0(@types/node@22.5.4)(rollup@4.28.1)(typescript@5.6.2) - '@astro-reactive/validator': 0.5.0(@types/node@22.5.4)(astro@5.0.5(@types/node@22.5.4)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1))(rollup@4.28.1)(typescript@5.6.2) - astro: 5.0.5(@types/node@22.5.4)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1) + '@astro-reactive/validator': 0.5.0(@types/node@22.5.4)(astro@5.0.5(@types/node@22.5.4)(jiti@2.4.2)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1))(rollup@4.28.1)(typescript@5.6.2) + astro: 5.0.5(@types/node@22.5.4)(jiti@2.4.2)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1) short-unique-id: 4.4.4 transitivePeerDependencies: - '@types/node' @@ -3573,10 +3597,10 @@ snapshots: - terser - typescript - '@astro-reactive/validator@0.5.0(@types/node@22.5.4)(astro@5.0.5(@types/node@22.5.4)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1))(rollup@4.28.1)(typescript@5.6.2)': + '@astro-reactive/validator@0.5.0(@types/node@22.5.4)(astro@5.0.5(@types/node@22.5.4)(jiti@2.4.2)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1))(rollup@4.28.1)(typescript@5.6.2)': dependencies: '@astro-reactive/common': 0.3.0(@types/node@22.5.4)(rollup@4.28.1)(typescript@5.6.2) - astro: 5.0.5(@types/node@22.5.4)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1) + astro: 5.0.5(@types/node@22.5.4)(jiti@2.4.2)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1) transitivePeerDependencies: - '@types/node' - less @@ -3605,10 +3629,10 @@ snapshots: import-meta-resolve: 4.1.0 mdast-util-definitions: 6.0.0 rehype-raw: 7.0.0 - rehype-stringify: 10.0.0 + rehype-stringify: 10.0.1 remark-gfm: 4.0.0 remark-parse: 11.0.0 - remark-rehype: 11.1.0 + remark-rehype: 11.1.1 remark-smartypants: 3.0.2 shiki: 1.17.6 unified: 11.0.5 @@ -4037,16 +4061,16 @@ snapshots: '@esbuild/win32-x64@0.24.0': optional: true - '@eslint-community/eslint-utils@4.4.1(eslint@9.17.0)': + '@eslint-community/eslint-utils@4.4.1(eslint@9.17.0(jiti@2.4.2))': dependencies: - eslint: 9.17.0 + eslint: 9.17.0(jiti@2.4.2) eslint-visitor-keys: 3.4.3 '@eslint-community/regexpp@4.12.1': {} - '@eslint/compat@1.2.4(eslint@9.17.0)': + '@eslint/compat@1.2.4(eslint@9.17.0(jiti@2.4.2))': optionalDependencies: - eslint: 9.17.0 + eslint: 9.17.0(jiti@2.4.2) '@eslint/config-array@0.19.1': dependencies: @@ -4365,7 +4389,7 @@ snapshots: '@shikijs/types': 1.17.6 '@shikijs/vscode-textmate': 9.2.2 '@types/hast': 3.0.4 - hast-util-to-html: 9.0.2 + hast-util-to-html: 9.0.4 '@shikijs/core@1.24.2': dependencies: @@ -4482,15 +4506,15 @@ snapshots: '@types/node': 22.5.4 optional: true - '@typescript-eslint/eslint-plugin@8.18.2(@typescript-eslint/parser@8.18.2(eslint@9.17.0)(typescript@5.6.2))(eslint@9.17.0)(typescript@5.6.2)': + '@typescript-eslint/eslint-plugin@8.18.2(@typescript-eslint/parser@8.18.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.2))(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.2)': dependencies: '@eslint-community/regexpp': 4.12.1 - '@typescript-eslint/parser': 8.18.2(eslint@9.17.0)(typescript@5.6.2) + '@typescript-eslint/parser': 8.18.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.2) '@typescript-eslint/scope-manager': 8.18.2 - '@typescript-eslint/type-utils': 8.18.2(eslint@9.17.0)(typescript@5.6.2) - '@typescript-eslint/utils': 8.18.2(eslint@9.17.0)(typescript@5.6.2) + '@typescript-eslint/type-utils': 8.18.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.2) + '@typescript-eslint/utils': 8.18.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.2) '@typescript-eslint/visitor-keys': 8.18.2 - eslint: 9.17.0 + eslint: 9.17.0(jiti@2.4.2) graphemer: 1.4.0 ignore: 5.3.2 natural-compare: 1.4.0 @@ -4499,14 +4523,14 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.18.2(eslint@9.17.0)(typescript@5.6.2)': + '@typescript-eslint/parser@8.18.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.2)': dependencies: '@typescript-eslint/scope-manager': 8.18.2 '@typescript-eslint/types': 8.18.2 '@typescript-eslint/typescript-estree': 8.18.2(typescript@5.6.2) '@typescript-eslint/visitor-keys': 8.18.2 debug: 4.4.0 - eslint: 9.17.0 + eslint: 9.17.0(jiti@2.4.2) typescript: 5.6.2 transitivePeerDependencies: - supports-color @@ -4516,12 +4540,12 @@ snapshots: '@typescript-eslint/types': 8.18.2 '@typescript-eslint/visitor-keys': 8.18.2 - '@typescript-eslint/type-utils@8.18.2(eslint@9.17.0)(typescript@5.6.2)': + '@typescript-eslint/type-utils@8.18.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.2)': dependencies: '@typescript-eslint/typescript-estree': 8.18.2(typescript@5.6.2) - '@typescript-eslint/utils': 8.18.2(eslint@9.17.0)(typescript@5.6.2) + '@typescript-eslint/utils': 8.18.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.2) debug: 4.4.0 - eslint: 9.17.0 + eslint: 9.17.0(jiti@2.4.2) ts-api-utils: 1.4.3(typescript@5.6.2) typescript: 5.6.2 transitivePeerDependencies: @@ -4543,13 +4567,13 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.18.2(eslint@9.17.0)(typescript@5.6.2)': + '@typescript-eslint/utils@8.18.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.2)': dependencies: - '@eslint-community/eslint-utils': 4.4.1(eslint@9.17.0) + '@eslint-community/eslint-utils': 4.4.1(eslint@9.17.0(jiti@2.4.2)) '@typescript-eslint/scope-manager': 8.18.2 '@typescript-eslint/types': 8.18.2 '@typescript-eslint/typescript-estree': 8.18.2(typescript@5.6.2) - eslint: 9.17.0 + eslint: 9.17.0(jiti@2.4.2) typescript: 5.6.2 transitivePeerDependencies: - supports-color @@ -4673,9 +4697,9 @@ snapshots: - supports-color - typescript - astro-github-stats@0.7.1(astro@5.0.5(@types/node@22.5.4)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1)): + astro-github-stats@0.7.1(astro@5.0.5(@types/node@22.5.4)(jiti@2.4.2)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1)): dependencies: - astro: 5.0.5(@types/node@22.5.4)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1) + astro: 5.0.5(@types/node@22.5.4)(jiti@2.4.2)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1) astro-iconify@1.2.0: dependencies: @@ -4770,7 +4794,7 @@ snapshots: - terser - typescript - astro@5.0.5(@types/node@22.5.4)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1): + astro@5.0.5(@types/node@22.5.4)(jiti@2.4.2)(rollup@4.28.1)(typescript@5.6.2)(yaml@2.6.1): dependencies: '@astrojs/compiler': 2.10.3 '@astrojs/internal-helpers': 0.4.2 @@ -4821,8 +4845,8 @@ snapshots: ultrahtml: 1.5.3 unist-util-visit: 5.0.0 vfile: 6.0.3 - vite: 6.0.3(@types/node@22.5.4)(yaml@2.6.1) - vitefu: 1.0.4(vite@6.0.3(@types/node@22.5.4)(yaml@2.6.1)) + vite: 6.0.3(@types/node@22.5.4)(jiti@2.4.2)(yaml@2.6.1) + vitefu: 1.0.4(vite@6.0.3(@types/node@22.5.4)(jiti@2.4.2)(yaml@2.6.1)) which-pm: 3.0.0 xxhash-wasm: 1.1.0 yargs-parser: 21.1.1 @@ -5057,6 +5081,8 @@ snapshots: confbox@0.1.8: {} + consola@3.3.3: {} + convert-source-map@2.0.0: {} cookie@0.6.0: {} @@ -5385,19 +5411,19 @@ snapshots: escape-string-regexp@5.0.0: {} - eslint-compat-utils@0.6.4(eslint@9.17.0): + eslint-compat-utils@0.6.4(eslint@9.17.0(jiti@2.4.2)): dependencies: - eslint: 9.17.0 + eslint: 9.17.0(jiti@2.4.2) semver: 7.6.3 - eslint-plugin-astro@1.3.1(eslint@9.17.0)(typescript@5.6.2): + eslint-plugin-astro@1.3.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.2): dependencies: - '@eslint-community/eslint-utils': 4.4.1(eslint@9.17.0) + '@eslint-community/eslint-utils': 4.4.1(eslint@9.17.0(jiti@2.4.2)) '@jridgewell/sourcemap-codec': 1.5.0 '@typescript-eslint/types': 8.18.2 astro-eslint-parser: 1.1.0(typescript@5.6.2) - eslint: 9.17.0 - eslint-compat-utils: 0.6.4(eslint@9.17.0) + eslint: 9.17.0(jiti@2.4.2) + eslint-compat-utils: 0.6.4(eslint@9.17.0(jiti@2.4.2)) globals: 15.14.0 postcss: 8.4.49 postcss-selector-parser: 7.0.0 @@ -5405,7 +5431,7 @@ snapshots: - supports-color - typescript - eslint-plugin-jsx-a11y@6.10.2(eslint@9.17.0): + eslint-plugin-jsx-a11y@6.10.2(eslint@9.17.0(jiti@2.4.2)): dependencies: aria-query: 5.3.2 array-includes: 3.1.8 @@ -5415,7 +5441,7 @@ snapshots: axobject-query: 4.1.0 damerau-levenshtein: 1.0.8 emoji-regex: 9.2.2 - eslint: 9.17.0 + eslint: 9.17.0(jiti@2.4.2) hasown: 2.0.2 jsx-ast-utils: 3.3.5 language-tags: 1.0.9 @@ -5433,9 +5459,9 @@ snapshots: eslint-visitor-keys@4.2.0: {} - eslint@9.17.0: + eslint@9.17.0(jiti@2.4.2): dependencies: - '@eslint-community/eslint-utils': 4.4.1(eslint@9.17.0) + '@eslint-community/eslint-utils': 4.4.1(eslint@9.17.0(jiti@2.4.2)) '@eslint-community/regexpp': 4.12.1 '@eslint/config-array': 0.19.1 '@eslint/core': 0.9.1 @@ -5469,6 +5495,8 @@ snapshots: minimatch: 3.1.2 natural-compare: 1.4.0 optionator: 0.9.4 + optionalDependencies: + jiti: 2.4.2 transitivePeerDependencies: - supports-color @@ -5774,20 +5802,6 @@ snapshots: web-namespaces: 2.0.1 zwitch: 2.0.4 - hast-util-to-html@9.0.2: - dependencies: - '@types/hast': 3.0.4 - '@types/unist': 3.0.3 - ccount: 2.0.1 - comma-separated-tokens: 2.0.3 - hast-util-whitespace: 3.0.0 - html-void-elements: 3.0.0 - mdast-util-to-hast: 13.2.0 - property-information: 6.5.0 - space-separated-tokens: 2.0.2 - stringify-entities: 4.0.4 - zwitch: 2.0.4 - hast-util-to-html@9.0.4: dependencies: '@types/hast': 3.0.4 @@ -6000,6 +6014,8 @@ snapshots: isexe@2.0.0: {} + jiti@2.4.2: {} + js-tokens@4.0.0: {} js-yaml@3.14.1: @@ -6670,6 +6686,8 @@ snapshots: pathe@1.1.2: {} + pathe@2.0.0: {} + pend@1.2.0: {} picocolors@1.1.0: {} @@ -6791,30 +6809,24 @@ snapshots: hast-util-raw: 9.0.4 vfile: 6.0.3 - rehype-stringify@10.0.0: - dependencies: - '@types/hast': 3.0.4 - hast-util-to-html: 9.0.2 - unified: 11.0.5 - rehype-stringify@10.0.1: dependencies: '@types/hast': 3.0.4 - hast-util-to-html: 9.0.2 + hast-util-to-html: 9.0.4 unified: 11.0.5 rehype@13.0.1: dependencies: '@types/hast': 3.0.4 rehype-parse: 9.0.0 - rehype-stringify: 10.0.0 + rehype-stringify: 10.0.1 unified: 11.0.5 rehype@13.0.2: dependencies: '@types/hast': 3.0.4 rehype-parse: 9.0.0 - rehype-stringify: 10.0.0 + rehype-stringify: 10.0.1 unified: 11.0.5 remark-gfm@4.0.0: @@ -6837,14 +6849,6 @@ snapshots: transitivePeerDependencies: - supports-color - remark-rehype@11.1.0: - dependencies: - '@types/hast': 3.0.4 - '@types/mdast': 4.0.4 - mdast-util-to-hast: 13.2.0 - unified: 11.0.5 - vfile: 6.0.3 - remark-rehype@11.1.1: dependencies: '@types/hast': 3.0.4 @@ -7302,12 +7306,12 @@ snapshots: possible-typed-array-names: 1.0.0 reflect.getprototypeof: 1.0.9 - typescript-eslint@8.18.2(eslint@9.17.0)(typescript@5.6.2): + typescript-eslint@8.18.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.2): dependencies: - '@typescript-eslint/eslint-plugin': 8.18.2(@typescript-eslint/parser@8.18.2(eslint@9.17.0)(typescript@5.6.2))(eslint@9.17.0)(typescript@5.6.2) - '@typescript-eslint/parser': 8.18.2(eslint@9.17.0)(typescript@5.6.2) - '@typescript-eslint/utils': 8.18.2(eslint@9.17.0)(typescript@5.6.2) - eslint: 9.17.0 + '@typescript-eslint/eslint-plugin': 8.18.2(@typescript-eslint/parser@8.18.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.2))(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.2) + '@typescript-eslint/parser': 8.18.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.2) + '@typescript-eslint/utils': 8.18.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.2) + eslint: 9.17.0(jiti@2.4.2) typescript: 5.6.2 transitivePeerDependencies: - supports-color @@ -7417,7 +7421,7 @@ snapshots: '@types/node': 22.5.4 fsevents: 2.3.3 - vite@6.0.3(@types/node@22.5.4)(yaml@2.6.1): + vite@6.0.3(@types/node@22.5.4)(jiti@2.4.2)(yaml@2.6.1): dependencies: esbuild: 0.24.0 postcss: 8.4.49 @@ -7425,15 +7429,16 @@ snapshots: optionalDependencies: '@types/node': 22.5.4 fsevents: 2.3.3 + jiti: 2.4.2 yaml: 2.6.1 vitefu@1.0.2(vite@5.4.5(@types/node@22.5.4)): optionalDependencies: vite: 5.4.5(@types/node@22.5.4) - vitefu@1.0.4(vite@6.0.3(@types/node@22.5.4)(yaml@2.6.1)): + vitefu@1.0.4(vite@6.0.3(@types/node@22.5.4)(jiti@2.4.2)(yaml@2.6.1)): optionalDependencies: - vite: 6.0.3(@types/node@22.5.4)(yaml@2.6.1) + vite: 6.0.3(@types/node@22.5.4)(jiti@2.4.2)(yaml@2.6.1) web-namespaces@2.0.1: {} diff --git a/src/constants/now.json b/src/constants/now.json new file mode 100644 index 0000000..1d2a02d --- /dev/null +++ b/src/constants/now.json @@ -0,0 +1,7 @@ +{ + "title": "Yes, New year!", + "description": "Oh what a feeling...", + "publishDate": "2025-01-04", + "publishedOn": "the fourth day of the first month of 2025", + "publishState": "after a weekend coding session" +} diff --git a/src/constants/now.md b/src/constants/now.md new file mode 100644 index 0000000..b4e2221 --- /dev/null +++ b/src/constants/now.md @@ -0,0 +1 @@ +something happened \ No newline at end of file diff --git a/src/constants/now.ts b/src/constants/now.ts deleted file mode 100644 index 7670230..0000000 --- a/src/constants/now.ts +++ /dev/null @@ -1,9 +0,0 @@ -const now = { - status: "Celebrating the year's end 🎉", - publishDate: '2024-12-25', - readableDate: 'the Christmas Day of 2024', - publishState: - 'while on the way home after a vacation in Germany; now onboard a train from Eindhoven to Amsterdam.', -} - -export default now diff --git a/src/pages/index.astro b/src/pages/index.astro index a152887..357a5ba 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -3,7 +3,7 @@ import Layout from '../layouts/Layout.astro' import Card from '../components/Card.astro' import Footer from '../components/Footer.astro' import { stuff } from '../constants/stuff' -import now from '../constants/now' +import now from '../constants/now.json' // const isDev = import.meta.env.DEV; // const getOriginUrl = (path: string) => isDev ? `http://localhost:5000/${path}` : path; @@ -36,7 +36,7 @@ import now from '../constants/now' Now - {now.status} + {now.title} diff --git a/src/pages/now.astro b/src/pages/now.astro index 942a8eb..cda871f 100644 --- a/src/pages/now.astro +++ b/src/pages/now.astro @@ -2,71 +2,34 @@ import Layout from '../layouts/Layout.astro' import Footer from '../components/Footer.astro' import Posts from '../components/Posts.astro' -import now from '../constants/now' +import now from '../constants/now.json' +import { dirname, resolve } from 'pathe' +import { readFileSync } from 'node:fs' +import { fileURLToPath } from 'node:url' +import { mdToHTML } from '../../commands/md-to-html' + +const __filename = fileURLToPath(import.meta.url) +const __dirname = dirname(__filename) +const nowMdPath = resolve(__dirname, '../constants/now.md') +const nowContent = readFileSync(nowMdPath, 'utf-8') +const nowHtml = await mdToHTML(nowContent) const posts = await Astro.glob('./now/and-then/posts/*.astro') ---
-

Now: {now.status}

+

Now: {now.title}

Published on {now.publishedOn ?? now.publishDate} {now.publishState}

-

Christmas holidays as started for me.

- -

- I think I finished all needed stuff for work. Also messaged people online - for a final happy holiday greetings of the year. Will go offline til - January and figure out my rhythm for next year. -

- -

- Reading Radical Candor by Kim Scott. Feels like a lot of these kind of - books are a rehash of concepts in "The 7 Habits of Highly Effective - People" and "How to Win Friends and Influence People" -- I recommend those - first before this one! I like that “humility” was also given a spotlight; - there's not enough attention to the effectivity/productivity of - acknowledging you can be wrong and welcoming feedback (both praise & - criticism). Hard to capture in a paragraph though -- ask me to elaborate - if you want and when given the chance! -

- -

- Also reinforced the idea that 'writing a story' in my head about people, - with prejudice, is unproductive. Assumptions are never good; always verify - before forming judgments and/or giving feedbacks. -

- -

- Spent some time in Aachen, Germany with the fam. Walked around the - Christmas Market there. Food trip galore, sat at cafes, read books, bought - stuff. :) -

- -

- But the highlight is going to Monschau on a day trip. Kahel buit a small - snowman. -

- -

- Also, realized down-time travel time is infinitely more productive when - listening to Audio books. It is especially effective for me for books I - have already finished and just need a review. So I am glad I have a copy - of the 7-habits book ready -- I finished that one years ago, listening to - the audio is mostly just a review. -

- -

- Stopping now before this becomes a long blog about books; seems I need to - write that separately... -

+
diff --git a/src/pages/now/and-then/posts/2024-12-25.astro b/src/pages/now/and-then/posts/2024-12-25.astro new file mode 100644 index 0000000..4768976 --- /dev/null +++ b/src/pages/now/and-then/posts/2024-12-25.astro @@ -0,0 +1,69 @@ +--- +import Layout from '../../../../layouts/Layout.astro' +import Footer from '../../../../components/Footer.astro' + +const title = `Yessss` +const description = `Closing the year and planning for the next` +const publishedOn = `the Christmas Day of 2024` +const publishDate = `2024-12-25` +const publishState = `while on the way home after a vacation in Germany; now onboard a train from Eindhoven to Amsterdam.` +const content = `

something happened

` +--- + + +
+

{title}

+

+ + Published on + + {publishState} + +

+ + + +
+
+
+ +