diff --git a/README.md b/README.md index 9776b51..f497770 100644 --- a/README.md +++ b/README.md @@ -112,26 +112,6 @@ To automatically output the text version when visiting the site via `curl`, you /blog/${1}.txt ``` 3. If you are using other web servers, you can use functions like `rewrite` or `redirect` by user agent (HTTP header) to achieve the same effect. -### Alternative Syntax Highlighting -Apart from the default shiki for highlighting, You can use [Prism](https://prismjs.com/) as code highlighting engine, see [Syntax Highlighting in Astro Docs](https://docs.astro.build/en/guides/syntax-highlighting/#add-a-prism-stylesheet) for details. - -To simply add features like code copying over the default Shiki formatter, you can simply import the `src/components/CodeScript.astro` to the Layout. - -You can also use [Expressive Code](https://expressive-code.com/) to get features like code copying over the syntax highlighting: -> Warning: Expressive Code will load JavaScript by default. This will not follow your `noClientJavaScript` settings. - -1. Install Expressive Code: - ```shell - pnpm astro add astro-expressive-code - ``` - You can answer all Yes to prompts as we will modify the config later. -2. Edit `astro.config.mjs`: - ```diff - - integrations: [sitemap(), mdx(), partytown(), expressiveCode()], - + integrations: [sitemap(), expressiveCode(), mdx(), partytown()], - ``` -3. Create `ec.config.mjs` in the project root and adjust the config to your liking. To make things easier you can use [this config file used by the author](https://raw.githubusercontent.com/BlockG-ws/gb-lab/refs/heads/master/ec.config.mjs) - ## 👀 Want to learn more? See the post [🕊](). I hope you like it. 💜 diff --git a/src/components/CodeScript.astro b/src/components/CodeScript.astro deleted file mode 100644 index 612466e..0000000 --- a/src/components/CodeScript.astro +++ /dev/null @@ -1,84 +0,0 @@ ---- -// from https://www.jaluwibowo.id/blog/en/custom-syntax-highlight-and-copy-feature/ ---- - - \ No newline at end of file diff --git a/src/content/posts/_schemas.ts b/src/content/posts/_schemas.ts index 3337edd..431b29d 100644 --- a/src/content/posts/_schemas.ts +++ b/src/content/posts/_schemas.ts @@ -1,15 +1,14 @@ -import {z, reference} from 'astro:content'; +import { z, reference } from 'astro:content'; // @ts-ignore -export const posts = ({image}) => z.object({ - title: z.string(), - description: z.string().optional(), - draft: z.boolean().optional().default(false), - summary: z.string().optional(), - date: z.coerce.date(), - updated: z.coerce.date().optional(), - categories: z.union([z.array(z.string()), z.string()]).transform(val => Array.isArray(val) ? val : [val]).default(['uncategorized']), - tags: z.array(z.string()).optional(), - cover: image().optional(), - author: z.union([z.array(reference('authors')), reference('authors')]).optional(), +export const posts = ({ image }) => z.object({ + title: z.string(), + description: z.string().optional(), + draft: z.boolean().optional().default(false), + summary: z.string().optional(), + date: z.coerce.date(), + categories: z.union([z.array(z.string()), z.string()]).transform(val => Array.isArray(val) ? val : [val]).default(['uncategorized']), + tags: z.array(z.string()).optional(), + cover: image().optional(), + author: z.union([z.array(reference('authors')), reference('authors')]).optional(), }); \ No newline at end of file diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index a4c5164..9b14a75 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -37,7 +37,7 @@ const wordcount = remarkPluginFrontmatter.wordcount; const lastUpdated = remarkPluginFrontmatter.lastModified; const pubDate = new Date(entry.data.date).toISOString().split('T')[0] -const lastUpdatedDate = entry.data.updated ? new Date(entry.data.updated).toISOString().split('T')[0] : new Date(lastUpdated).toISOString().split('T')[0]; +const lastUpdatedDate = new Date(lastUpdated).toISOString().split('T')[0] // Get author data const authorData = await Promise.all((author).map((singleAuthor) => getEntry(singleAuthor).then(authorEntry => authorEntry?.data))) @@ -46,7 +46,7 @@ const authorInfo = authorData.includes(undefined) ? [{data: siteConfig.defaultA // get featured image and use it as og:image // use the custom cover image if it exists, otherwise use the featured image file in the same directory const featuredImages = import.meta.glob(`/src/content/posts/*/featured.{avif,png,jpg,jpeg,webp}`,{import:'default',eager:true}); -const customFeaturedImage = entry.data.cover +const customFeaturedImage = entry.data.cover?.src const matchedImage = Object.keys(featuredImages).find(path => path.includes(slug)); let matchedImage_src; if (matchedImage && !customFeaturedImage) {