From ddf2eed21ef3cf08d4a463a04aca427173da8920 Mon Sep 17 00:00:00 2001 From: Kebo Kitanari Date: Tue, 12 Nov 2024 14:51:24 -0600 Subject: [PATCH] fixes to get the compile actually working (slightly hacky lol) --- astro.config.mjs | 3 +- package.json | 5 +-- pnpm-lock.yaml | 14 ++++++-- src/_components.ts | 8 ++--- src/components/Footer.astro | 3 ++ src/components/Icon.astro | 5 +-- src/components/mdx/MDXCodeBlock.astro | 9 +++-- src/components/mdx/PostHeader.tsx | 48 --------------------------- src/layouts/BaseLayout.astro | 2 +- src/layouts/PostLayout.astro | 11 +++--- src/layouts/StandaloneMDXLayout.astro | 6 ++-- src/lib/blog.ts | 4 +-- src/lib/feed.ts | 18 +++++----- src/lib/utils.ts | 4 ++- src/pages/blog.astro | 29 ++++++++-------- src/pages/feeds/feed.json.ts | 4 +-- src/pages/feeds/feed.xml.ts | 5 ++- src/pages/index.astro | 16 +++++---- src/pages/newest/index.ts | 5 ++- src/pages/posts/[...slug].astro | 1 - src/pages/sharefeed.astro | 15 +++------ 21 files changed, 88 insertions(+), 127 deletions(-) delete mode 100644 src/components/mdx/PostHeader.tsx diff --git a/astro.config.mjs b/astro.config.mjs index 7527ab6..e103bbb 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -41,10 +41,9 @@ export default defineConfig({ }, integrations: [react(), tailwind(), mdx({ - syntaxHighlight: 'false', + syntaxHighlight: false, remarkPlugins: [[m2dx, m2dxOptions]], rehypePlugins: [rehypeSlug, [rehypeMdxCodeProps, {tagName: 'code'}]], - extendDefaultPlugins: true, }), icon()], output: 'server', diff --git a/package.json b/package.json index 892c647..787c8bf 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "0.0.1", "scripts": { "dev": "astro dev", - "start": "astro dev", + "start": "astro start -p 8080", "build": "astro check && astro build", "preview": "astro preview", "astro": "astro" @@ -29,7 +29,6 @@ "feed": "^4.2.2", "github-slugger": "^2.0.0", "linkedom": "^0.18.5", - "lodash": "^4.17.21", "prism": "^4.1.2", "prism-react-renderer": "^2.4.0", "react": "^18.3.1", @@ -45,8 +44,10 @@ }, "packageManager": "pnpm@9.10.0+sha512.73a29afa36a0d092ece5271de5177ecbf8318d454ecd701343131b8ebc0c1a91c487da46ab77c8e596d6acf1461e3594ced4becedf8921b074fbd8653ed7051c", "devDependencies": { + "@types/lodash": "^4.17.13", "astro-auto-import": "^0.4.4", "astro-mdx-code-blocks": "^0.0.6", + "lodash": "^4.17.21", "node-html-parser": "^6.1.13" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fad0b75..18787d7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -65,9 +65,6 @@ importers: linkedom: specifier: ^0.18.5 version: 0.18.5 - lodash: - specifier: ^4.17.21 - version: 4.17.21 prism: specifier: ^4.1.2 version: 4.1.2(react@18.3.1) @@ -105,12 +102,18 @@ importers: specifier: ^5.6.2 version: 5.6.2 devDependencies: + '@types/lodash': + specifier: ^4.17.13 + version: 4.17.13 astro-auto-import: specifier: ^0.4.4 version: 0.4.4(astro@4.16.10(@types/node@18.19.55)(rollup@4.24.0)(typescript@5.6.2)) astro-mdx-code-blocks: specifier: ^0.0.6 version: 0.0.6(astro@4.16.10(@types/node@18.19.55)(rollup@4.24.0)(typescript@5.6.2)) + lodash: + specifier: ^4.17.21 + version: 4.17.21 node-html-parser: specifier: ^6.1.13 version: 6.1.13 @@ -835,6 +838,9 @@ packages: '@types/hast@3.0.4': resolution: {integrity: sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==} + '@types/lodash@4.17.13': + resolution: {integrity: sha512-lfx+dftrEZcdBPczf9d0Qv0x+j/rfNCMuC6OcfXmO8gkfeNAY88PgKUbvG56whcN23gc27yenwF6oJZXGFpYxg==} + '@types/mdast@3.0.15': resolution: {integrity: sha512-LnwD+mUEfxWMa1QpDraczIn6k0Ee3SMicuYSSzS6ZYl2gKS09EClnJYGd8Du6rfc5r/GZEk5o1mRb8TaTj03sQ==} @@ -4058,6 +4064,8 @@ snapshots: dependencies: '@types/unist': 3.0.3 + '@types/lodash@4.17.13': {} + '@types/mdast@3.0.15': dependencies: '@types/unist': 2.0.11 diff --git a/src/_components.ts b/src/_components.ts index 2c6652d..0c18595 100644 --- a/src/_components.ts +++ b/src/_components.ts @@ -1,7 +1,7 @@ -import HR from '/src/components/HR.astro' -import MDXImage from '/src/components/mdx/MDXImage.astro' -import MDXCallout from '/src/components/mdx/MDXCallout.astro' -import MDXCodeBlock from '/src/components/mdx/MDXCodeBlock.astro' +import HR from './components/HR.astro' +import MDXImage from './components/mdx/MDXImage.astro' +import MDXCallout from './components/mdx/MDXCallout.astro' +import MDXCodeBlock from './components/mdx/MDXCodeBlock.astro' export const components = { hr: HR, diff --git a/src/components/Footer.astro b/src/components/Footer.astro index 6ec3ffe..1f6eb3a 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -11,14 +11,17 @@ const iconClass = 'fill-current hover:fill-crusta-800 dark:hover:fill-night-400'
contact —  + {/* @ts-ignore */} + {/* @ts-ignore */} + {/* @ts-ignore */} diff --git a/src/components/Icon.astro b/src/components/Icon.astro index d27b4cd..5bf2a38 100644 --- a/src/components/Icon.astro +++ b/src/components/Icon.astro @@ -5,7 +5,7 @@ import { parse } from 'node-html-parser'; // https://ellodave.dev/blog/article/using-svgs-as-astro-components-and-inline-css/ export interface Props { - icon: string; + icon: string } function getSVG(name: string) { @@ -21,6 +21,7 @@ function getSVG(name: string) { const root = parse(files[filepath]); const svg = root.querySelector('svg'); + // @ts-ignore const { attributes, innerHTML } = svg; return { @@ -29,7 +30,7 @@ function getSVG(name: string) { }; } -const { icon, ...attributes } = Astro.props as Props; +const { icon, ...attributes } = Astro.props; const { attributes: baseAttributes, innerHTML } = getSVG(icon); const svgAttributes = { ...baseAttributes, ...attributes }; diff --git a/src/components/mdx/MDXCodeBlock.astro b/src/components/mdx/MDXCodeBlock.astro index 4a136dc..cb41b5a 100644 --- a/src/components/mdx/MDXCodeBlock.astro +++ b/src/components/mdx/MDXCodeBlock.astro @@ -1,6 +1,8 @@ --- -import React, { ReactNode } from 'react'; +import React from 'react'; +import type { ReactNode } from 'react'; + //import { CodeBlock } from 'react-code-block'; //import { themes } from 'prism-react-renderer'; import { Highlight } from 'prism-react-renderer'; @@ -46,14 +48,15 @@ let filename: string = ''; const code_html = await Astro.slots.render('default'); +// @ts-ignore const renderCode = (html) => { const { document } = parseHTML(html); const child = document.children const match = /language-(\w+)/.exec(child[0].className); lang = match ? match[1] : 'plaintext'; - const match2 = /filename="(.*?)"/.exec(child[0].getAttribute('metastring')) - filename = match2 ? match2[1] : null; + const match2 = /filename="(.*?)"/.exec(child[0].getAttribute('metastring') ?? '') + filename = match2 ? match2[1] : ''; //console.log(match) return unescape(child[0].innerHTML); } diff --git a/src/components/mdx/PostHeader.tsx b/src/components/mdx/PostHeader.tsx deleted file mode 100644 index 0e3e7a9..0000000 --- a/src/components/mdx/PostHeader.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import { Post } from "@/.contentlayer/generated" -import MDXImage from "./MDXImage" - -import { format, parseISO } from 'date-fns' - -export default function PostHeader(post: Post) { - - const numberToWord = (num: number) => { - switch(num) { - case 1: return "one"; - case 2: return "two"; - case 3: return "three"; - case 4: return "four"; - } - } - - return (<> - { ( post.cover && post.cover_alt ) ? ( -
- -
- ) : '' } - -

{post.title}

-

— {format(parseISO(post.date), 'LLLL d, yyyy')} - {(post.updated) ? ( - , updated {format(parseISO(post.updated), 'LLLL d, yyyy')} - ) : ''} -

-

{post.summary}

- - {(post.toc) ? ( <> -

table of contents

-
- {post.headings.map((heading: {level: number, text: string, slug: string}) => { - return ( -
- - {(heading.level > 1) ? '> ' : ''} - {heading.text} - -
- ) - })} -
- ):''} - ) -} \ No newline at end of file diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index f3b83d2..a12e80f 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -20,7 +20,7 @@ const { title } = Astro.props {title ? title + ' - eleboog.com' : 'eleboog.com'} - +
diff --git a/src/layouts/PostLayout.astro b/src/layouts/PostLayout.astro index 2c5e1f0..d7af443 100644 --- a/src/layouts/PostLayout.astro +++ b/src/layouts/PostLayout.astro @@ -6,6 +6,7 @@ import '../styles/markdown.css' import { format } from 'date-fns' import { toZonedTime } from 'date-fns-tz' +import { timeZone } from "../lib/utils"; import Header from '../components/Header.astro' import Footer from '../components/Footer.astro' @@ -13,8 +14,6 @@ import MDXImage from '../components/mdx/MDXImage.astro' import HR from '../components/HR.astro' -import { mdxComponents } from '@l/mdx.tsx'; - const fm = Astro.props.frontmatter const headings = await Astro.props.headings @@ -40,7 +39,7 @@ const numberToWord = (num: number) => { {title ? title + ' - eleboog.com' : 'eleboog.com'} - +
{ ( fm.cover && fm.cover_alt ) ? ( @@ -50,9 +49,9 @@ const numberToWord = (num: number) => { ) : '' }

{fm.title}

-

— {format(toZonedTime(fm.date), 'LLLL d, yyyy')} +

— {format(toZonedTime(fm.date, timeZone), 'LLLL d, yyyy')} {(fm.updated) ? ( - , updated {format(toZonedTime(fm.updated), 'LLLL d, yyyy')} + , updated {format(toZonedTime(fm.updated, timeZone), 'LLLL d, yyyy')} ) : ''}

{fm.summary}

@@ -73,7 +72,7 @@ const numberToWord = (num: number) => {
{headings.map((heading: {depth: number, slug: string, text: string}) => { return ( -
+
{(heading.depth > 1) ? '> ' : ''} {heading.text} diff --git a/src/layouts/StandaloneMDXLayout.astro b/src/layouts/StandaloneMDXLayout.astro index 95157d1..c7ae802 100644 --- a/src/layouts/StandaloneMDXLayout.astro +++ b/src/layouts/StandaloneMDXLayout.astro @@ -9,8 +9,6 @@ import Footer from '../components/Footer.astro' import HR from '../components/HR.astro' -import { mdxComponents } from '@l/mdx.tsx'; - const { frontmatter } = Astro.props const title = frontmatter.slug ?? 'me' @@ -26,14 +24,14 @@ const title = frontmatter.slug ?? 'me' {title ? title + ' - eleboog.com' : 'eleboog.com'} - +

{frontmatter.title}

{frontmatter.summary}

- +