fixes to get the compile actually working (slightly hacky lol)

This commit is contained in:
Kebo Kitanari 2024-11-12 14:51:24 -06:00
parent 48fc1c29a6
commit ddf2eed21e
21 changed files with 88 additions and 127 deletions

View file

@ -41,10 +41,9 @@ export default defineConfig({
}, },
integrations: [react(), tailwind(), mdx({ integrations: [react(), tailwind(), mdx({
syntaxHighlight: 'false', syntaxHighlight: false,
remarkPlugins: [[m2dx, m2dxOptions]], remarkPlugins: [[m2dx, m2dxOptions]],
rehypePlugins: [rehypeSlug, [rehypeMdxCodeProps, {tagName: 'code'}]], rehypePlugins: [rehypeSlug, [rehypeMdxCodeProps, {tagName: 'code'}]],
extendDefaultPlugins: true,
}), icon()], }), icon()],
output: 'server', output: 'server',

View file

@ -4,7 +4,7 @@
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"dev": "astro dev", "dev": "astro dev",
"start": "astro dev", "start": "astro start -p 8080",
"build": "astro check && astro build", "build": "astro check && astro build",
"preview": "astro preview", "preview": "astro preview",
"astro": "astro" "astro": "astro"
@ -29,7 +29,6 @@
"feed": "^4.2.2", "feed": "^4.2.2",
"github-slugger": "^2.0.0", "github-slugger": "^2.0.0",
"linkedom": "^0.18.5", "linkedom": "^0.18.5",
"lodash": "^4.17.21",
"prism": "^4.1.2", "prism": "^4.1.2",
"prism-react-renderer": "^2.4.0", "prism-react-renderer": "^2.4.0",
"react": "^18.3.1", "react": "^18.3.1",
@ -45,8 +44,10 @@
}, },
"packageManager": "pnpm@9.10.0+sha512.73a29afa36a0d092ece5271de5177ecbf8318d454ecd701343131b8ebc0c1a91c487da46ab77c8e596d6acf1461e3594ced4becedf8921b074fbd8653ed7051c", "packageManager": "pnpm@9.10.0+sha512.73a29afa36a0d092ece5271de5177ecbf8318d454ecd701343131b8ebc0c1a91c487da46ab77c8e596d6acf1461e3594ced4becedf8921b074fbd8653ed7051c",
"devDependencies": { "devDependencies": {
"@types/lodash": "^4.17.13",
"astro-auto-import": "^0.4.4", "astro-auto-import": "^0.4.4",
"astro-mdx-code-blocks": "^0.0.6", "astro-mdx-code-blocks": "^0.0.6",
"lodash": "^4.17.21",
"node-html-parser": "^6.1.13" "node-html-parser": "^6.1.13"
} }
} }

14
pnpm-lock.yaml generated
View file

@ -65,9 +65,6 @@ importers:
linkedom: linkedom:
specifier: ^0.18.5 specifier: ^0.18.5
version: 0.18.5 version: 0.18.5
lodash:
specifier: ^4.17.21
version: 4.17.21
prism: prism:
specifier: ^4.1.2 specifier: ^4.1.2
version: 4.1.2(react@18.3.1) version: 4.1.2(react@18.3.1)
@ -105,12 +102,18 @@ importers:
specifier: ^5.6.2 specifier: ^5.6.2
version: 5.6.2 version: 5.6.2
devDependencies: devDependencies:
'@types/lodash':
specifier: ^4.17.13
version: 4.17.13
astro-auto-import: astro-auto-import:
specifier: ^0.4.4 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)) 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: astro-mdx-code-blocks:
specifier: ^0.0.6 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)) 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: node-html-parser:
specifier: ^6.1.13 specifier: ^6.1.13
version: 6.1.13 version: 6.1.13
@ -835,6 +838,9 @@ packages:
'@types/hast@3.0.4': '@types/hast@3.0.4':
resolution: {integrity: sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==} 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': '@types/mdast@3.0.15':
resolution: {integrity: sha512-LnwD+mUEfxWMa1QpDraczIn6k0Ee3SMicuYSSzS6ZYl2gKS09EClnJYGd8Du6rfc5r/GZEk5o1mRb8TaTj03sQ==} resolution: {integrity: sha512-LnwD+mUEfxWMa1QpDraczIn6k0Ee3SMicuYSSzS6ZYl2gKS09EClnJYGd8Du6rfc5r/GZEk5o1mRb8TaTj03sQ==}
@ -4058,6 +4064,8 @@ snapshots:
dependencies: dependencies:
'@types/unist': 3.0.3 '@types/unist': 3.0.3
'@types/lodash@4.17.13': {}
'@types/mdast@3.0.15': '@types/mdast@3.0.15':
dependencies: dependencies:
'@types/unist': 2.0.11 '@types/unist': 2.0.11

View file

@ -1,7 +1,7 @@
import HR from '/src/components/HR.astro' import HR from './components/HR.astro'
import MDXImage from '/src/components/mdx/MDXImage.astro' import MDXImage from './components/mdx/MDXImage.astro'
import MDXCallout from '/src/components/mdx/MDXCallout.astro' import MDXCallout from './components/mdx/MDXCallout.astro'
import MDXCodeBlock from '/src/components/mdx/MDXCodeBlock.astro' import MDXCodeBlock from './components/mdx/MDXCodeBlock.astro'
export const components = { export const components = {
hr: HR, hr: HR,

View file

@ -11,14 +11,17 @@ const iconClass = 'fill-current hover:fill-crusta-800 dark:hover:fill-night-400'
<HR/> <HR/>
<div class="flex items-center">contact&ensp;&mdash;&ensp; <div class="flex items-center">contact&ensp;&mdash;&ensp;
<a href='https://plush.city/@kebokyo' target='_blank' rel='noopener noreferrer' aria-label="fediverse"> <a href='https://plush.city/@kebokyo' target='_blank' rel='noopener noreferrer' aria-label="fediverse">
{/* @ts-ignore */}
<Icon icon="PiFediverseLogoFill" class={iconClass} title="fediverse" aria-label="fediverse"/> <Icon icon="PiFediverseLogoFill" class={iconClass} title="fediverse" aria-label="fediverse"/>
</a> </a>
&emsp; &emsp;
<a href='https://bsky.app/profile/kebokyo.eleboog.com' target='_blank' rel='noopener noreferrer' aria-label="bluesky"> <a href='https://bsky.app/profile/kebokyo.eleboog.com' target='_blank' rel='noopener noreferrer' aria-label="bluesky">
{/* @ts-ignore */}
<Icon icon="FaBluesky" class={iconClass} title="bluesky" aria-label="bluesky"/> <Icon icon="FaBluesky" class={iconClass} title="bluesky" aria-label="bluesky"/>
</a> </a>
&emsp; &emsp;
<a href='mailto:kebokyo@eleboog.com' target='_blank' rel='noopener noreferrer' aria-label="email"> <a href='mailto:kebokyo@eleboog.com' target='_blank' rel='noopener noreferrer' aria-label="email">
{/* @ts-ignore */}
<Icon icon="MdMail" class={iconClass} title="email" aria-label="email"/> <Icon icon="MdMail" class={iconClass} title="email" aria-label="email"/>
</a> </a>

View file

@ -5,7 +5,7 @@ import { parse } from 'node-html-parser';
// https://ellodave.dev/blog/article/using-svgs-as-astro-components-and-inline-css/ // https://ellodave.dev/blog/article/using-svgs-as-astro-components-and-inline-css/
export interface Props { export interface Props {
icon: string; icon: string
} }
function getSVG(name: string) { function getSVG(name: string) {
@ -21,6 +21,7 @@ function getSVG(name: string) {
const root = parse(files[filepath]); const root = parse(files[filepath]);
const svg = root.querySelector('svg'); const svg = root.querySelector('svg');
// @ts-ignore
const { attributes, innerHTML } = svg; const { attributes, innerHTML } = svg;
return { 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 { attributes: baseAttributes, innerHTML } = getSVG(icon);
const svgAttributes = { ...baseAttributes, ...attributes }; const svgAttributes = { ...baseAttributes, ...attributes };

View file

@ -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 { CodeBlock } from 'react-code-block';
//import { themes } from 'prism-react-renderer'; //import { themes } from 'prism-react-renderer';
import { Highlight } 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'); const code_html = await Astro.slots.render('default');
// @ts-ignore
const renderCode = (html) => { const renderCode = (html) => {
const { document } = parseHTML(html); const { document } = parseHTML(html);
const child = document.children const child = document.children
const match = /language-(\w+)/.exec(child[0].className); const match = /language-(\w+)/.exec(child[0].className);
lang = match ? match[1] : 'plaintext'; lang = match ? match[1] : 'plaintext';
const match2 = /filename="(.*?)"/.exec(child[0].getAttribute('metastring')) const match2 = /filename="(.*?)"/.exec(child[0].getAttribute('metastring') ?? '')
filename = match2 ? match2[1] : null; filename = match2 ? match2[1] : '';
//console.log(match) //console.log(match)
return unescape(child[0].innerHTML); return unescape(child[0].innerHTML);
} }

View file

@ -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 ) ? (
<div className="mb-4">
<MDXImage src={post.cover} alt={post.cover_alt}/>
</div>
) : '' }
<h1 className="text-4xl font-serif font-bold text-title">{post.title}</h1>
<h2 className="font-mono">&mdash; {format(parseISO(post.date), 'LLLL d, yyyy')}
{(post.updated) ? (
<span>, <span className="text-subtitle">updated {format(parseISO(post.updated), 'LLLL d, yyyy')}</span></span>
) : ''}
</h2>
<h2 className="text-sm italic mb-4 text-subtitle">{post.summary}</h2>
{(post.toc) ? ( <>
<h3 className="font-mono text-xl text-title">table of contents</h3>
<div id="toc" className="mb-4 ml-2 pl-2 border-l border-neutral-400 ">
{post.headings.map((heading: {level: number, text: string, slug: string}) => {
return (
<div key={`#${heading.slug}`}>
<a className="font-serif text-sm text-subtitle hover:underline data-[level=two]:pl-3 data-[level=three]:pl-6" data-level={numberToWord(heading.level)} href={'#' + heading.slug}>
{(heading.level > 1) ? '> ' : ''}
{heading.text}
</a>
</div>
)
})}
</div>
</>):''}
</>)
}

View file

@ -20,7 +20,7 @@ const { title } = Astro.props
<meta name="generator" content={Astro.generator} /> <meta name="generator" content={Astro.generator} />
<title>{title ? title + ' - eleboog.com' : 'eleboog.com'}</title> <title>{title ? title + ' - eleboog.com' : 'eleboog.com'}</title>
</head> </head>
<body class="flex-col mx-auto min-h-screen max-w-screen-md p-8 py-4""> <body class="flex-col mx-auto min-h-screen max-w-screen-md p-8 py-4">
<Header current={title}/> <Header current={title}/>
<main> <main>
<slot/> <slot/>

View file

@ -6,6 +6,7 @@ import '../styles/markdown.css'
import { format } from 'date-fns' import { format } from 'date-fns'
import { toZonedTime } from 'date-fns-tz' import { toZonedTime } from 'date-fns-tz'
import { timeZone } from "../lib/utils";
import Header from '../components/Header.astro' import Header from '../components/Header.astro'
import Footer from '../components/Footer.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 HR from '../components/HR.astro'
import { mdxComponents } from '@l/mdx.tsx';
const fm = Astro.props.frontmatter const fm = Astro.props.frontmatter
const headings = await Astro.props.headings const headings = await Astro.props.headings
@ -40,7 +39,7 @@ const numberToWord = (num: number) => {
<meta name="generator" content={Astro.generator} /> <meta name="generator" content={Astro.generator} />
<title>{title ? title + ' - eleboog.com' : 'eleboog.com'}</title> <title>{title ? title + ' - eleboog.com' : 'eleboog.com'}</title>
</head> </head>
<body class="flex-col mx-auto min-h-screen max-w-screen-md p-8 py-4""> <body class="flex-col mx-auto min-h-screen max-w-screen-md p-8 py-4">
<Header current='blog post'/> <Header current='blog post'/>
<main> <main>
{ ( fm.cover && fm.cover_alt ) ? ( { ( fm.cover && fm.cover_alt ) ? (
@ -50,9 +49,9 @@ const numberToWord = (num: number) => {
) : '' } ) : '' }
<h1 class="text-4xl font-serif font-bold text-title">{fm.title}</h1> <h1 class="text-4xl font-serif font-bold text-title">{fm.title}</h1>
<h2 class="font-mono">&mdash; {format(toZonedTime(fm.date), 'LLLL d, yyyy')} <h2 class="font-mono">&mdash; {format(toZonedTime(fm.date, timeZone), 'LLLL d, yyyy')}
{(fm.updated) ? ( {(fm.updated) ? (
<span>, <span class="text-subtitle">updated {format(toZonedTime(fm.updated), 'LLLL d, yyyy')}</span></span> <span>, <span class="text-subtitle">updated {format(toZonedTime(fm.updated, timeZone), 'LLLL d, yyyy')}</span></span>
) : ''} ) : ''}
</h2> </h2>
<h2 class="text-sm italic mb-4 mt-2 text-subtitle">{fm.summary}</h2> <h2 class="text-sm italic mb-4 mt-2 text-subtitle">{fm.summary}</h2>
@ -73,7 +72,7 @@ const numberToWord = (num: number) => {
<div id="toc" class="mb-4 ml-2 pl-2 border-l border-neutral-400 "> <div id="toc" class="mb-4 ml-2 pl-2 border-l border-neutral-400 ">
{headings.map((heading: {depth: number, slug: string, text: string}) => { {headings.map((heading: {depth: number, slug: string, text: string}) => {
return ( return (
<div key={`#${heading.slug}`}> <div>
<a class="font-serif text-sm text-subtitle hover:underline data-[level=two]:pl-3 data-[level=three]:pl-6" data-level={numberToWord(heading.depth)} href={'#' + heading.slug}> <a class="font-serif text-sm text-subtitle hover:underline data-[level=two]:pl-3 data-[level=three]:pl-6" data-level={numberToWord(heading.depth)} href={'#' + heading.slug}>
{(heading.depth > 1) ? '> ' : ''} {(heading.depth > 1) ? '> ' : ''}
{heading.text} {heading.text}

View file

@ -9,8 +9,6 @@ import Footer from '../components/Footer.astro'
import HR from '../components/HR.astro' import HR from '../components/HR.astro'
import { mdxComponents } from '@l/mdx.tsx';
const { frontmatter } = Astro.props const { frontmatter } = Astro.props
const title = frontmatter.slug ?? 'me' const title = frontmatter.slug ?? 'me'
@ -26,14 +24,14 @@ const title = frontmatter.slug ?? 'me'
<meta name="generator" content={Astro.generator} /> <meta name="generator" content={Astro.generator} />
<title>{title ? title + ' - eleboog.com' : 'eleboog.com'}</title> <title>{title ? title + ' - eleboog.com' : 'eleboog.com'}</title>
</head> </head>
<body class="flex-col mx-auto min-h-screen max-w-screen-md p-8 py-4""> <body class="flex-col mx-auto min-h-screen max-w-screen-md p-8 py-4">
<Header current={title}/> <Header current={title}/>
<main> <main>
<h1 class="text-3xl font-serif my-2">{frontmatter.title}</h1> <h1 class="text-3xl font-serif my-2">{frontmatter.title}</h1>
<h2 class="text-sm mb-4 text-subtitle">{frontmatter.summary}</h2> <h2 class="text-sm mb-4 text-subtitle">{frontmatter.summary}</h2>
<article> <article>
<slot components={{hr: HR}}/> <slot />
</article> </article>
</main> </main>
<Footer/> <Footer/>

View file

@ -1,6 +1,6 @@
export allTags = [ export const allTags = [
// type of content // type of content
"meta", "reply", "self-promo", "rant", "critique", "tutorial" "meta", "reply", "self-promo", "rant", "critique", "tutorial",
// mood // mood
"silly", "angry", "curious", "happy", "sad", "introspective", "silly", "angry", "curious", "happy", "sad", "introspective",
// topic // topic

View file

@ -1,11 +1,11 @@
import { getCollection, getEntry } from "astro:content"; import { getCollection } from "astro:content";
import { Feed } from "feed"; import { Feed } from "feed";
import { compareDesc } from "date-fns" import { compareDesc } from "date-fns"
import { toZonedTime } from 'date-fns-tz' import { toZonedTime } from 'date-fns-tz'
import sfjson from '/src/data/sharefeed.json' import sfjson from '../data/sharefeed.json'
import type { ShareFeedEntry } from "/src/lib/utils"; import type { ShareFeedEntry } from "../lib/utils";
export const baseURL = "localhost:4321"//"https://eleboog.com" export const baseURL = "localhost:4321"//"https://eleboog.com"
export const author = { export const author = {
@ -14,6 +14,8 @@ export const author = {
link: baseURL link: baseURL
}; };
import { timeZone } from "./utils";
export async function computeFeed() { export async function computeFeed() {
const mainFeed = new Feed({ const mainFeed = new Feed({
title: "eleboog.com feed", title: "eleboog.com feed",
@ -63,7 +65,7 @@ export function addSharefeedEntriesToFeed(feed: Feed, main?: boolean) {
author: [{ author: [{
name: entry.author name: entry.author
}], }],
date: toZonedTime(entry.date) date: toZonedTime(entry.date, timeZone)
}) })
}) })
} }
@ -71,11 +73,11 @@ export function addSharefeedEntriesToFeed(feed: Feed, main?: boolean) {
export async function addPostsToFeed(feed: Feed, main?: boolean) { export async function addPostsToFeed(feed: Feed, main?: boolean) {
const posts = await getCollection('posts') const posts = await getCollection('posts')
posts.sort((a:Post,b:Post) => compareDesc(new Date(a.data.date), new Date(b.data.date))) posts.sort((a, b) => compareDesc(new Date(a.data.date), new Date(b.data.date)))
.filter((post:Post) => !post.data.draft) .filter((post) => !post.data.draft)
.slice(0,20); .slice(0,20);
posts.forEach((post: Post) => { posts.forEach((post) => {
const url: string = `${baseURL}/posts/${post.id}` const url: string = `${baseURL}/posts/${post.id}`
let title: string = ''; let title: string = '';
if (main) { if (main) {
@ -90,7 +92,7 @@ export async function addPostsToFeed(feed: Feed, main?: boolean) {
description: post.data.summary ?? "Whoops, I didn't write a summary for this. Yell at me that I need to do so.", description: post.data.summary ?? "Whoops, I didn't write a summary for this. Yell at me that I need to do so.",
content: post.data.summary ?? "Whoops, I didn't write a summary for this. Yell at me that I need to do so.", content: post.data.summary ?? "Whoops, I didn't write a summary for this. Yell at me that I need to do so.",
author: [author], author: [author],
date: toZonedTime(post.data.date), date: toZonedTime(post.data.date, timeZone),
}); });
}) })
} }

View file

@ -8,4 +8,6 @@ export type ShareFeedEntry = {
title: string, title: string,
note: string, note: string,
draft?: boolean draft?: boolean
} }
export const timeZone = "America/Chicago";

View file

@ -1,15 +1,14 @@
--- ---
import { compareDesc, format, parseISO } from 'date-fns' import { compareDesc, format } from 'date-fns'
import { fromZonedTime, toZonedTime } from 'date-fns-tz' import { toZonedTime } from 'date-fns-tz'
import { timeZone } from "../lib/utils";
import BaseLayout from '../layouts/BaseLayout.astro'; import BaseLayout from '../layouts/BaseLayout.astro';
import cri from "./chills_going_waaaaah.png"
import { Picture } from 'astro:assets';
import HR from "../components/HR.astro" import HR from "../components/HR.astro"
import { getCollection, getEntry } from 'astro:content'; import { getCollection } from 'astro:content';
const posts = await getCollection('posts'); const posts = await getCollection('posts');
const archives = await getCollection('archives'); const archives = await getCollection('archives');
@ -22,13 +21,13 @@ const archives = await getCollection('archives');
<h2 class="text-2xl font-serif text-crusta-600 dark:text-night-200 my-2">current content</h2> <h2 class="text-2xl font-serif text-crusta-600 dark:text-night-200 my-2">current content</h2>
<ul class="space-y-2"> <ul class="space-y-2">
{posts.sort((a, b) => compareDesc(new Date(a.data.date), new Date(b.data.date))).map((post, idx, array) => { {posts.sort((a, b) => compareDesc(new Date(a.data.date), new Date(b.data.date))).map((post) => {
if (post.data.archive) return; if (post.data.draft) return;
console.log(toZonedTime(post.data.date)); console.log(toZonedTime(post.data.date, timeZone));
return ( return (
<li key={idx}> <li>
<a href={'/posts/' + post.slug} class="font-serif text-lg text-crusta-400 dark:text-night-300 hover:underline">{post.data.title}</a> <a href={'/posts/' + post.slug} class="font-serif text-lg text-crusta-400 dark:text-night-300 hover:underline">{post.data.title}</a>
&emsp;<span class="font-mono text-md">{format(toZonedTime(post.data.date), 'LLL d, yyyy')}</span> &emsp;<span class="font-mono text-md">{format(toZonedTime(post.data.date, timeZone), 'LLL d, yyyy')}</span>
<p>{post.data.summary}</p> <p>{post.data.summary}</p>
</li> </li>
); );
@ -42,13 +41,13 @@ const archives = await getCollection('archives');
Please check the date of publication before making any comments.</p> Please check the date of publication before making any comments.</p>
<ul class="space-y-2"> <ul class="space-y-2">
{archives.sort((a, b) => compareDesc(new Date(a.data.date), new Date(b.data.date))).map((post, idx, array) => { {archives.sort((a, b) => compareDesc(new Date(a.data.date), new Date(b.data.date))).map((post) => {
if (post.data.archive) return; if (post.data.draft) return;
console.log(toZonedTime(post.data.date)); console.log(toZonedTime(post.data.date, timeZone));
return ( return (
<li key={idx}> <li>
<a href={'/posts/' + post.slug} class="font-serif text-lg text-crusta-400 dark:text-night-300 hover:underline">{post.data.title}</a> <a href={'/posts/' + post.slug} class="font-serif text-lg text-crusta-400 dark:text-night-300 hover:underline">{post.data.title}</a>
&emsp;<span class="font-mono text-md">{format(toZonedTime(post.data.date), 'LLL d, yyyy')}</span> &emsp;<span class="font-mono text-md">{format(toZonedTime(post.data.date, timeZone), 'LLL d, yyyy')}</span>
<p>{post.data.summary}</p> <p>{post.data.summary}</p>
</li> </li>
); );

View file

@ -1,7 +1,7 @@
import { computeFeed } from "/src/lib/feed.ts"; import { computeFeed } from "../../lib/feed.ts";
import type { APIContext } from 'astro'; import type { APIContext } from 'astro';
export async function GET({request, url, cookies}: APIContext): Promise<Response> { export async function GET(context: APIContext): Promise<Response> {
const feed = await computeFeed(); const feed = await computeFeed();
return new Response(feed.json1()) return new Response(feed.json1())

View file

@ -1,7 +1,6 @@
import { computeFeed, injectXSL } from "/src/lib/feed.ts"; import { computeFeed, injectXSL } from "../../lib/feed.ts";
import type { APIContext } from 'astro';
export async function GET({request, url, cookies}: APIContext): Promise<Response> { export async function GET(): Promise<Response> {
const feed = await computeFeed(); const feed = await computeFeed();
return new Response(injectXSL(feed.atom1(), "/feed.xsl")) return new Response(injectXSL(feed.atom1(), "/feed.xsl"))

View file

@ -1,7 +1,7 @@
--- ---
import { compareDesc, format, parseISO } from 'date-fns' import { compareDesc, format } from 'date-fns'
import { fromZonedTime, toZonedTime } from 'date-fns-tz' import { toZonedTime } from 'date-fns-tz'
import BaseLayout from '../layouts/BaseLayout.astro'; import BaseLayout from '../layouts/BaseLayout.astro';
import cri from "./chills_going_waaaaah.png" import cri from "./chills_going_waaaaah.png"
@ -9,10 +9,12 @@ import { Picture } from 'astro:assets';
import MDXCallout from "../components/mdx/MDXCallout.astro" import MDXCallout from "../components/mdx/MDXCallout.astro"
import { getCollection, getEntry } from 'astro:content'; import { getCollection } from 'astro:content';
const posts = await getCollection('posts') const posts = await getCollection('posts')
import { timeZone } from "../lib/utils";
--- ---
<BaseLayout title="home"> <BaseLayout title="home">
@ -44,13 +46,13 @@ const posts = await getCollection('posts')
<h2 class="font-serif text-2xl mb-2">recent posts</h2> <h2 class="font-serif text-2xl mb-2">recent posts</h2>
<ul class="space-y-2"> <ul class="space-y-2">
{posts.sort((a, b) => compareDesc(new Date(a.data.date), new Date(b.data.date))).map((post, idx, array) => { {posts.sort((a, b) => compareDesc(new Date(a.data.date), new Date(b.data.date))).map((post, idx) => {
if (idx >= 3 || post.data.draft) return; if (idx >= 3 || post.data.draft) return;
console.log(toZonedTime(post.data.date)); console.log(toZonedTime(post.data.date, timeZone));
return ( return (
<li key={idx}> <li >
<a href={'/posts/' + post.slug} class="font-serif text-lg text-crusta-400 dark:text-night-300 hover:underline">{post.data.title}</a> <a href={'/posts/' + post.slug} class="font-serif text-lg text-crusta-400 dark:text-night-300 hover:underline">{post.data.title}</a>
&emsp;<span class="font-mono text-md">{format(toZonedTime(post.data.date), 'LLL d, yyyy')}</span> &emsp;<span class="font-mono text-md">{format(toZonedTime(post.data.date, timeZone), 'LLL d, yyyy')}</span>
<p>{post.data.summary}</p> <p>{post.data.summary}</p>
</li> </li>
); );

View file

@ -1,7 +1,6 @@
import { compareDesc, format, parseISO } from 'date-fns' import { compareDesc } from 'date-fns'
import { fromZonedTime, toZonedTime } from 'date-fns-tz'
import { getCollection, getEntry } from 'astro:content'; import { getCollection } from 'astro:content';
import type { APIRoute } from 'astro'; import type { APIRoute } from 'astro';

View file

@ -2,7 +2,6 @@
export const prerender = true; export const prerender = true;
import {getCollection} from 'astro:content' import {getCollection} from 'astro:content'
import PostLayout from '../../layouts/PostLayout.astro'
export async function getStaticPaths() { export async function getStaticPaths() {
const posts = await getCollection('posts'); const posts = await getCollection('posts');

View file

@ -1,6 +1,6 @@
--- ---
import { compareDesc, format, parseISO } from 'date-fns' import { compareDesc, format } from 'date-fns'
import { toZonedTime } from 'date-fns-tz' import { toZonedTime } from 'date-fns-tz'
import BaseLayout from '../layouts/BaseLayout.astro'; import BaseLayout from '../layouts/BaseLayout.astro';
@ -8,13 +8,11 @@ import BaseLayout from '../layouts/BaseLayout.astro';
import HR from "../components/HR.astro"; import HR from "../components/HR.astro";
import MDXCallout from '../components/mdx/MDXCallout.astro'; import MDXCallout from '../components/mdx/MDXCallout.astro';
import { getCollection, getEntry } from 'astro:content';
import sfjson from "../data/sharefeed.json"; import sfjson from "../data/sharefeed.json";
import type { ShareFeedEntry } from "../lib/utils"; import type { ShareFeedEntry } from "../lib/utils";
const entries = sfjson.sharefeed const entries = sfjson.sharefeed
.sort((a:ShareFeedEntry,b:ShareFeedEntry) => compareDesc(new Date(a.posted), new Date(b.posted))) .sort((a:ShareFeedEntry,b:ShareFeedEntry) => compareDesc(new Date(a.date), new Date(b.date)))
.filter((entry: ShareFeedEntry) => !(entry.draft)) .filter((entry: ShareFeedEntry) => !(entry.draft))
--- ---
@ -28,10 +26,9 @@ const entries = sfjson.sharefeed
<HR/> <HR/>
<ul classs="space-y-2"> <ul class="space-y-2">
{entries.map((entry: ShareFeedEntry, idx: number, array: ShareFeedEntry[]) => ( {entries.map((entry: ShareFeedEntry) => (
<> <li class="mb-2">
<li key={idx} class="mb-2">
<a href={entry.url} class="font-serif text-lg text-crusta-400 dark:text-night-300 hover:underline"> <a href={entry.url} class="font-serif text-lg text-crusta-400 dark:text-night-300 hover:underline">
{entry.author ? `${entry.author}: ` : ''} {entry.author ? `${entry.author}: ` : ''}
{entry.title} {entry.title}
@ -43,8 +40,6 @@ const entries = sfjson.sharefeed
</p> </p>
<p>{entry.note}</p> <p>{entry.note}</p>
</li> </li>
{((idx + 1) % 10 == 0) ? (<HR/>) : ''}
</>
))} ))}
</ul> </ul>
</BaseLayout> </BaseLayout>