refactor: renamed md to posts, and plaintext to files
This commit is contained in:
parent
20811f107b
commit
e4052fc145
7 changed files with 13 additions and 13 deletions
|
|
@ -28,4 +28,4 @@ const bookmarks = defineCollection({
|
|||
})
|
||||
});
|
||||
|
||||
export const collections = { md, bookmarks };
|
||||
export const collections = { posts, bookmarks };
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ export const SUBDOMAINS = [
|
|||
];
|
||||
|
||||
export const SECTIONS = {
|
||||
plaintext: 'plaintext',
|
||||
files: 'files',
|
||||
bookmarks: 'bookmarks',
|
||||
guestbook: 'guestbook',
|
||||
} as const;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import type { CollectionEntry } from 'astro:content';
|
|||
import { DEFAULT_CATEGORY } from './consts';
|
||||
import { sortEntries } from './format';
|
||||
|
||||
export type Post = CollectionEntry<'md'> & { body?: string };
|
||||
export type Post = CollectionEntry<'posts'> & { body?: string };
|
||||
|
||||
export function getSlug(postId: string): string {
|
||||
const parts = postId.split('/');
|
||||
|
|
@ -2,10 +2,10 @@
|
|||
import { getCollection, render } from 'astro:content';
|
||||
import Layout from '../layouts/Layout.astro';
|
||||
import { formatDate, formatListItem, excerpt, wordCount } from '../lib/format';
|
||||
import { getSlug, resolveRelatedPosts, type Post } from '../lib/md';
|
||||
import { getSlug, resolveRelatedPosts, type Post } from '../lib/posts';
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const allPosts = await getCollection('md');
|
||||
const allPosts = await getCollection('posts');
|
||||
return allPosts.map(post => ({
|
||||
params: { slug: getSlug(post.id) },
|
||||
props: { post, allPosts }
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import rss from '@astrojs/rss';
|
||||
import { getCollection } from 'astro:content';
|
||||
import type { APIContext } from 'astro';
|
||||
import { getSlug, type Post } from '../lib/md';
|
||||
import { getSlug, type Post } from '../lib/posts';
|
||||
import { getTxtFiles } from '../lib/txt';
|
||||
import { excerpt } from '../lib/format';
|
||||
|
||||
export async function GET(context: APIContext) {
|
||||
const posts = await getCollection('md');
|
||||
const posts = await getCollection('posts');
|
||||
const txtFiles = getTxtFiles();
|
||||
|
||||
const items = [
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ import { getCollection } from 'astro:content';
|
|||
import Layout from '../layouts/Layout.astro';
|
||||
import { getApprovedEntries, type GuestbookEntry } from '../lib/db';
|
||||
import { formatDate, formatListItem, extractDomain, wordCount, escapeHtml } from '../lib/format';
|
||||
import { organizePostsByCategory, getSlug } from '../lib/md';
|
||||
import { organizePostsByCategory, getSlug } from '../lib/posts';
|
||||
import { getTxtFiles } from '../lib/txt';
|
||||
import { DEFAULT_CATEGORY, SECTIONS, SUBDOMAINS } from '../lib/consts';
|
||||
|
||||
const posts = await getCollection('md');
|
||||
const posts = await getCollection('posts');
|
||||
const { grouped, categories: sortedCategories } = organizePostsByCategory(posts);
|
||||
|
||||
const bookmarksCollection = await getCollection('bookmarks');
|
||||
|
|
@ -43,8 +43,8 @@ const urls = [
|
|||
);
|
||||
})}
|
||||
|
||||
<section data-section={SECTIONS.plaintext}>
|
||||
<a class="section-label" href={`?just=${SECTIONS.plaintext}`}>{SECTIONS.plaintext}</a>
|
||||
<section data-section={SECTIONS.files}>
|
||||
<a class="section-label" href={`?just=${SECTIONS.files}`}>{SECTIONS.files}</a>
|
||||
<div class="entry-list" set:html={txtFiles.map(f => {
|
||||
const name = f.name.replace(/\.txt$/, '');
|
||||
return `<span class="entry">${formatListItem(f.date, `/${f.name}`, name, { suffix: f.description })}</span>`;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import { getCollection } from 'astro:content';
|
||||
import type { APIContext } from 'astro';
|
||||
import { getSlug } from '../lib/md';
|
||||
import { getSlug } from '../lib/posts';
|
||||
import { getTxtFiles } from '../lib/txt';
|
||||
import { SUBDOMAINS } from '../lib/consts';
|
||||
|
||||
export async function GET(context: APIContext) {
|
||||
const site = context.site?.origin ?? 'https://wynne.rs';
|
||||
const posts = await getCollection('md');
|
||||
const posts = await getCollection('posts');
|
||||
const txtFiles = getTxtFiles().map(f => f.name);
|
||||
|
||||
const urls = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue