From 9978be7288550961a392147ed868c192a68f9800 Mon Sep 17 00:00:00 2001 From: Izan Gil <66965250+SrIzan10@users.noreply.github.com> Date: Sun, 26 May 2024 14:26:43 +0200 Subject: [PATCH] feat: make landing responsive --- src/pages/blog/[...slug].astro | 47 +++++++++++++++++----------------- src/pages/index.astro | 4 +-- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index 196e577..47afc96 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -1,40 +1,39 @@ --- import BlogPost from '../../layouts/BlogPost.astro' -import { ghostClient } from '../../lib/ghost'; -import type { PostOrPage } from '@tryghost/content-api'; +import { ghostClient } from '../../lib/ghost' +import type { PostOrPage } from '@tryghost/content-api' import * as shiki from 'shiki' import { JSDOM } from 'jsdom' export async function getStaticPaths() { - const posts = await ghostClient.posts - .browse({ - limit: 'all', - }); - return posts.map((post) => { - return { - params: { - slug: post.slug, - }, - props: { - post: post, - }, - }; - }); + const posts = await ghostClient.posts.browse({ + limit: 'all', + }) + return posts.map((post) => { + return { + params: { + slug: post.slug, + }, + props: { + post: post, + }, + } + }) } -const { post } = Astro.props as { post: PostOrPage }; +const { post } = Astro.props as { post: PostOrPage } // parse the post.html content, get the code blocks and highlight them const doc = new JSDOM(post.html!) const codeBlocks = doc.window.document.querySelectorAll('code') for (const codeBlock of codeBlocks) { if (!codeBlock.className) continue - const language = codeBlock.className.replace('language-', '') - const code = codeBlock.textContent - const rendered = await shiki.codeToHtml(code!, { - lang: language, - theme: 'tokyo-night', - }) - codeBlock.innerHTML = rendered + const language = codeBlock.className.replace('language-', '') + const code = codeBlock.textContent + const rendered = await shiki.codeToHtml(code!, { + lang: language, + theme: 'tokyo-night', + }) + codeBlock.innerHTML = rendered } --- diff --git a/src/pages/index.astro b/src/pages/index.astro index f8dd499..930f40d 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -23,8 +23,8 @@ const randomBackground = Backgrounds[Math.floor(Math.random() * Backgrounds.leng
-
- {'pfp'} +
+ {'pfp'}

Hobbyist developer & sern lead developer team member