Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
joevaugh4n committed Dec 17, 2024
1 parent 4e9c62e commit bc7ad1f
Show file tree
Hide file tree
Showing 28 changed files with 435 additions and 552 deletions.
2 changes: 0 additions & 2 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import icon from 'astro-icon'
import starlight from '@astrojs/starlight'
import react from '@astrojs/react'

import compress from 'astro-compress'

// https://astro.build/config
export default defineConfig({
integrations: [
Expand Down
Binary file removed blogpost_screenshot.png
Binary file not shown.
Binary file removed blogpost_screenshot_chromium.png
Binary file not shown.
Binary file removed blogpost_screenshot_firefox.png
Binary file not shown.
Binary file removed blogpost_screenshot_webkit.png
Binary file not shown.
Binary file removed chromium_blogpost_screenshot.png
Binary file not shown.
Binary file removed chromium_homepage_screenshot.png
Binary file not shown.
Binary file removed chromium_posts_page_screenshot.png
Binary file not shown.
Binary file removed firefox_blogpost_screenshot.png
Binary file not shown.
Binary file removed firefox_homepage_screenshot.png
Binary file not shown.
Binary file removed firefox_posts_page_screenshot.png
Binary file not shown.
Binary file removed homepage_screenshot.png
Binary file not shown.
Binary file removed homepage_screenshot_chromium.png
Binary file not shown.
Binary file removed homepage_screenshot_firefox.png
Binary file not shown.
Binary file removed homepage_screenshot_webkit.png
Binary file not shown.
881 changes: 412 additions & 469 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"astro-google-fonts-optimizer": "^0.2.2",
"astro-icon": "^1.1.0",
"astro-social-share": "^2.0.2",
"dompurify": "^3.2.3",
"html-entities": "^2.5.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"tailwindcss": "^3.4.7",
Expand Down
78 changes: 0 additions & 78 deletions playwright.config.ts

This file was deleted.

Binary file removed posts_page.png
Binary file not shown.
Binary file removed posts_page_chromium.png
Binary file not shown.
Binary file removed posts_page_firefox.png
Binary file not shown.
Binary file removed posts_page_webkit.png
Binary file not shown.
Binary file removed screenshot.png
Binary file not shown.
2 changes: 2 additions & 0 deletions src/components/Posts.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ interface Props {
const { title } = Astro.props;
const { posts } = await fetchBlogPosts();
const uniqueTags = getUniqueTags(posts.nodes);
console.log(posts)
---

<section id="posts" class="min-h-screen max-w-7xl mx-auto w-full">
Expand Down
22 changes: 19 additions & 3 deletions src/lib/posts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { wpquery } from "./wordpress";
import { decode } from "html-entities";

interface Tag {
name: string;
Expand All @@ -20,12 +21,18 @@ interface DataProps {
};
}

function sanitizeExcerpt(input: string): string {
const noHtml = input.replace(/<\/?[^>]+(>|$)/g, ""); // Remove HTML tags
const decoded = decode(noHtml); // Decode HTML entities
return decoded.trim().replace(/\n/g, ""); // Remove newlines and trim
}

export async function fetchBlogPosts(): Promise<DataProps> {
try {
const response = await wpquery({
query: `
query GetPostExcerptsAndAllTags {
posts {
posts(first:1000) {
nodes {
title
dateGmt
Expand All @@ -51,7 +58,11 @@ export async function fetchBlogPosts(): Promise<DataProps> {
});

if (response.posts?.nodes) {
return response as DataProps;
const sanitizedPosts = response.posts.nodes.map((post) => ({
...post,
excerpt: sanitizeExcerpt(post.excerpt),
}));
return { posts: { nodes: sanitizedPosts } };
} else {
return { posts: { nodes: [] } };
}
Expand Down Expand Up @@ -85,7 +96,11 @@ export async function fetchLatestPost(): Promise<PostProps> {
});

if (response.posts?.nodes?.[0]) {
return response.posts.nodes[0];
const latestPost = response.posts.nodes[0];
return {
...latestPost,
excerpt: sanitizeExcerpt(latestPost.excerpt),
};
} else {
return {
dateGmt: '',
Expand All @@ -106,6 +121,7 @@ export async function fetchLatestPost(): Promise<PostProps> {
}
}


export function getUniqueTags(posts: PostProps[]): Tag[] {
const tagsSet = new Set();
posts.forEach((post) => {
Expand Down
Binary file removed webkit_blogpost_screenshot.png
Binary file not shown.
Binary file removed webkit_homepage_screenshot.png
Binary file not shown.
Binary file removed webkit_posts_page_screenshot.png
Binary file not shown.

0 comments on commit bc7ad1f

Please sign in to comment.