Add blog app scaffolding with remark plugins

This commit is contained in:
Lewis Wynne 2026-01-23 00:07:23 +00:00
parent 9d9f213bbe
commit 0b8b50cf12
5 changed files with 84 additions and 0 deletions

View file

@ -0,0 +1,19 @@
import { defineConfig } from 'astro/config';
import remarkDirective from 'remark-directive';
import remarkGfm from 'remark-gfm';
import remarkSlug from 'remark-slug';
import remarkSmartypants from 'remark-smartypants';
import remarkAside from './src/plugins/remark-aside.ts';
export default defineConfig({
output: 'static',
markdown: {
remarkPlugins: [
remarkGfm,
remarkDirective,
remarkAside,
remarkSlug,
remarkSmartypants
]
}
});

18
apps/blog/package.json Normal file
View file

@ -0,0 +1,18 @@
{
"name": "@ily/blog",
"type": "module",
"scripts": {
"dev": "astro dev --port 4322",
"build": "astro build",
"preview": "astro preview"
},
"dependencies": {
"astro": "^5.16.13"
},
"devDependencies": {
"remark-directive": "^3.0.0",
"remark-gfm": "^4.0.0",
"remark-slug": "^7.0.1",
"remark-smartypants": "^3.0.2"
}
}

View file

@ -0,0 +1,13 @@
import { defineCollection } from 'astro:content';
import { glob } from 'astro/loaders';
import { z } from 'astro/zod';
const posts = defineCollection({
loader: glob({ pattern: '**/*.md', base: './src/content/posts' }),
schema: z.object({
title: z.string(),
date: z.coerce.date()
})
});
export const collections = { posts };

View file

@ -0,0 +1,14 @@
import { visit } from 'unist-util-visit';
import type { Root } from 'mdast';
export default function remarkAside() {
return (tree: Root) => {
visit(tree, 'textDirective', (node: any) => {
if (node.name !== 'aside') return;
const data = node.data || (node.data = {});
data.hName = 'span';
data.hProperties = { class: 'aside' };
});
};
}

View file

@ -0,0 +1,20 @@
body {
max-width: 38rem;
margin: 0 auto;
padding: 1rem;
}
.aside {
display: block;
font-size: 0.9rem;
}
@media (min-width: 63rem) {
.aside {
display: inline;
float: right;
position: relative;
width: 10rem;
margin-right: -12rem;
}
}