EmDash installed - server mode, basic integration. Visual editor wiring deferred to fix build errors.
This commit is contained in:
6
src/live.config.ts
Normal file
6
src/live.config.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { defineLiveCollection } from "astro:content";
|
||||
import { emdashLoader } from "emdash/runtime";
|
||||
|
||||
export const collections = {
|
||||
_emdash: defineLiveCollection({ loader: emdashLoader() }),
|
||||
};
|
||||
23
src/utils/site-identity.ts
Normal file
23
src/utils/site-identity.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { emdash } from "emdash/astro";
|
||||
import type { CollectionEntry } from "astro:content";
|
||||
|
||||
export async function getSiteSettings() {
|
||||
const context = await emdash(Astro);
|
||||
const settings = context.entries.settings?.[0];
|
||||
return settings;
|
||||
}
|
||||
|
||||
export function resolveBlogSiteIdentity(entry: CollectionEntry<"blog">) {
|
||||
return {
|
||||
title: entry.data.title,
|
||||
description: entry.data.excerpt,
|
||||
image: entry.data.image,
|
||||
};
|
||||
}
|
||||
|
||||
export function getReadingTime(content: string): string {
|
||||
const wordsPerMinute = 200;
|
||||
const words = content.split(/\s+/).length;
|
||||
const minutes = Math.ceil(words / wordsPerMinute);
|
||||
return `${minutes} นาที`;
|
||||
}
|
||||
Reference in New Issue
Block a user