From 0077087a5179c2ffdec07ee38f3ffbbb01853dde Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sat, 3 Feb 2024 14:08:16 -0500 Subject: Guestbook; No more hardcoded date --- src/layouts/Default.astro | 3 ++- src/pages/blog/index.astro | 1 - src/pages/blog/rss.xml.js | 31 +++++++++++++++++++++++++++++++ src/pages/contacts.astro | 2 +- src/pages/guestbook.astro | 19 +++++++++++++++++++ src/pages/projects.astro | 20 ++++++++++++-------- src/pages/rss.xml.js | 31 ------------------------------- src/styles/index.css | 1 + 8 files changed, 66 insertions(+), 42 deletions(-) create mode 100644 src/pages/blog/rss.xml.js create mode 100644 src/pages/guestbook.astro delete mode 100644 src/pages/rss.xml.js (limited to 'src') diff --git a/src/layouts/Default.astro b/src/layouts/Default.astro index 25a7ce4..17e9a92 100644 --- a/src/layouts/Default.astro +++ b/src/layouts/Default.astro @@ -7,6 +7,7 @@ interface Props { const { title = "Andrew Lee", description = "Andrew Lee Website" } = Astro.props; import { ViewTransitions } from 'astro:transitions'; import Navbar from '../components/Navbar.vue'; +const date = new Date(); --- @@ -42,7 +43,7 @@ import Navbar from '../components/Navbar.vue'; diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro index 74f543a..a6b6855 100644 --- a/src/pages/blog/index.astro +++ b/src/pages/blog/index.astro @@ -8,7 +8,6 @@ const allBlogPosts = (await getCollection('blog')).sort((a, b) => b.data.pubDate ---
- {allBlogPosts.map((post) => (

{post.data.title}

diff --git a/src/pages/blog/rss.xml.js b/src/pages/blog/rss.xml.js new file mode 100644 index 0000000..fe17f91 --- /dev/null +++ b/src/pages/blog/rss.xml.js @@ -0,0 +1,31 @@ +import rss from '@astrojs/rss'; +import { getCollection } from "astro:content"; +import sanitizeHtml from 'sanitize-html'; +import MarkdownIt from 'markdown-it'; +const parser = new MarkdownIt(); + +export async function GET(context) { + const blog = await getCollection('blog'); + return rss({ + // `` field in output xml + title: 'Andrew Lee', + // `<description>` field in output xml + description: 'Andrew Lee\'s Personal Blog', + // Pull in your project "site" from the endpoint context + // https://docs.astro.build/en/reference/api-reference/#contextsite + site: context.site, + // Array of `<item>`s in output xml + // See "Generating items" section for examples using content collections and glob imports + items: blog.map((post) => ({ + title: post.data.title, + pubDate: post.data.pubDate, + description: post.data.description, + // Compute RSS link from post `slug` + // This example assumes all posts are rendered as `/blog/[slug]` routes + link: `/blog/${post.slug}/`, + content: sanitizeHtml(parser.render(post.body)), + // (optional) inject custom xml + customData: `<language>en-us</language>`, + })), + }); +} diff --git a/src/pages/contacts.astro b/src/pages/contacts.astro index d483f81..c65c6f9 100644 --- a/src/pages/contacts.astro +++ b/src/pages/contacts.astro @@ -28,7 +28,7 @@ import contacts from "../data/contacts.json"; } .contact-icon { - margin-right: 0.5em; + margin: 0.1em 0.5em 0.1em 0.1em; font-size: 1.3em; } </style> diff --git a/src/pages/guestbook.astro b/src/pages/guestbook.astro new file mode 100644 index 0000000..0827802 --- /dev/null +++ b/src/pages/guestbook.astro @@ -0,0 +1,19 @@ +--- +import Page from '../layouts/Page.astro' +import "../styles/cards.css"; +--- +<Page title="Guestbook" description="Use this page to send me a message"> + <main> + <article> + <h1>John Doe</h1> + <small>January 1, 2024</small> + <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Nam id orci non diam bibendum euismod quis sit amet purus. + Fusce fermentum facilisis placerat. Mauris varius ante elit, et + luctus enim blandit sit amet. + Pellentesque ullamcorper dapibus suscipit. + </p> + <a href="http://google.com">Website</a> + </article> + </main> +</Page> diff --git a/src/pages/projects.astro b/src/pages/projects.astro index a4f121a..d609211 100644 --- a/src/pages/projects.astro +++ b/src/pages/projects.astro @@ -10,11 +10,13 @@ import projects from "../data/projects.json"; <div class="cards"> <h1>{project.name}</h1> <p>{project.description}</p> - {project.links.map((link) => { - return ( - <a href={link.url} target={link.external ? "_blank" : ""}>{link.name}</a> - ) - })} + <div class="row"> + {project.links.map((link) => { + return ( + <a href={link.url} target={link.external ? "_blank" : "_self"}>{link.name}</a> + ) + })} + </div> </div> ) }) @@ -48,9 +50,11 @@ import projects from "../data/projects.json"; margin: 0; } - .cards a { - text-align: right; - display: inline-block; + .row { + margin-top: 0.3em; + display: flex; + flex-direction: row; + gap: 1em; } /* Mobile view */ diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js deleted file mode 100644 index fe17f91..0000000 --- a/src/pages/rss.xml.js +++ /dev/null @@ -1,31 +0,0 @@ -import rss from '@astrojs/rss'; -import { getCollection } from "astro:content"; -import sanitizeHtml from 'sanitize-html'; -import MarkdownIt from 'markdown-it'; -const parser = new MarkdownIt(); - -export async function GET(context) { - const blog = await getCollection('blog'); - return rss({ - // `<title>` field in output xml - title: 'Andrew Lee', - // `<description>` field in output xml - description: 'Andrew Lee\'s Personal Blog', - // Pull in your project "site" from the endpoint context - // https://docs.astro.build/en/reference/api-reference/#contextsite - site: context.site, - // Array of `<item>`s in output xml - // See "Generating items" section for examples using content collections and glob imports - items: blog.map((post) => ({ - title: post.data.title, - pubDate: post.data.pubDate, - description: post.data.description, - // Compute RSS link from post `slug` - // This example assumes all posts are rendered as `/blog/[slug]` routes - link: `/blog/${post.slug}/`, - content: sanitizeHtml(parser.render(post.body)), - // (optional) inject custom xml - customData: `<language>en-us</language>`, - })), - }); -} diff --git a/src/styles/index.css b/src/styles/index.css index 1b5a8ca..ae3e9db 100644 --- a/src/styles/index.css +++ b/src/styles/index.css @@ -22,6 +22,7 @@ justify-content: center; font-size: 3.2em; gap: 1.4em; + margin: 0.2em; } .email-contact { -- cgit v1.2.3