Skip to content

Commit d0cdbff

Browse files
committed
Fix QA-718 page regressions and broken host page links
1 parent 5618a7c commit d0cdbff

6 files changed

Lines changed: 434 additions & 81 deletions

File tree

public/favicon.ico

1.03 KB
Binary file not shown.

src/components/PostCard.astro

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ interface Props {
1919
const { post, compact = false } = Astro.props;
2020
const href = post.data.path;
2121
const hasImage = Boolean(post.data.featuredImage);
22-
const categorySlug = post.data.categories[0];
23-
const categoryLabel = categorySlug
24-
? taxonomy.categories[categorySlug as keyof typeof taxonomy.categories] ?? categorySlug
25-
: '';
22+
const categoryChips = post.data.categories.map((slug) => ({
23+
slug,
24+
label: taxonomy.categories[slug as keyof typeof taxonomy.categories] ?? slug
25+
}));
26+
const summary = post.data.description?.replace(/\s+/g, ' ').trim() ?? '';
2627
---
2728

2829
<article class:list={['post-card', compact && 'post-card--compact']}>
@@ -44,15 +45,24 @@ const categoryLabel = categorySlug
4445
}
4546

4647
<div class="post-card__body">
47-
{categorySlug && (
48-
<a class="post-card__category" href={`/category/${categorySlug}/`}>
49-
{categoryLabel}
50-
</a>
48+
{categoryChips.length > 0 && (
49+
<div class="post-card__categories">
50+
{categoryChips.map((category) => (
51+
<a class="post-card__category" href={`/category/${category.slug}/`}>
52+
{category.label}
53+
</a>
54+
))}
55+
</div>
5156
)}
5257
<h2 class="post-card__title">
5358
<a href={href}>{post.data.title}</a>
5459
</h2>
5560
<p class="meta">{post.data.date.toISOString().slice(0, 10)}</p>
56-
{!compact && post.data.description && <p class="post-card__summary">{post.data.description}</p>}
61+
{!compact && summary && <p class="post-card__summary">{summary}</p>}
62+
{!compact && (
63+
<p class="post-card__readmore">
64+
<a href={href}>Read More →</a>
65+
</p>
66+
)}
5767
</div>
5868
</article>

src/layouts/BaseLayout.astro

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const isActive = (href: string) => {
4545
<meta property="og:type" content="website" />
4646
<meta property="og:url" content={canonicalUrl ?? Astro.url.toString()} />
4747
<meta name="twitter:card" content="summary_large_image" />
48+
<link rel="icon" href="/favicon.ico" sizes="any" />
4849
{canonicalUrl && <link rel="canonical" href={canonicalUrl} />}
4950
<slot name="head" />
5051
<title>{title}</title>
@@ -66,7 +67,11 @@ const isActive = (href: string) => {
6667
{
6768
navLinks.map((link) => (
6869
<a
69-
class:list={['top-nav__link', isActive(link.href) && 'is-active']}
70+
class:list={[
71+
'top-nav__link',
72+
isActive(link.href) && 'is-active',
73+
link.href.startsWith('http') && 'is-external'
74+
]}
7075
href={link.href}
7176
target={link.href.startsWith('http') ? '_blank' : undefined}
7277
rel={link.href.startsWith('http') ? 'noreferrer' : undefined}

src/pages/[...slug].astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export async function getStaticPaths() {
1414
1515
const byPath = new Map(allEntries.map((entry) => [entry.data.path, entry] as const));
1616
const aliasPathToCanonicalPath = new Map<string, string>([
17+
['/hichee-blog-for-hosts/page/2/', '/hichee-blog-for-hosts/'],
1718
['/where-am-i-24-2/', '/where-am-i-24/'],
1819
[
1920
'/best-cheap-flights-websites-nobody-is-talking-about-how-to-find-cheap-flights-2022\uFFFC/',

src/pages/index.astro

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const pages = (await getCollection('pages')).filter((entry) => !entry.data.draft
66
const homePage = pages.find((entry) => entry.data.wordpressId === 156 || entry.data.path === '/the-hichee-blog/');
77
88
const legacyHomeHtml = homePage ? rewriteHomeHtml(homePage.body) : '';
9+
const homeShareHtml = buildHomeShareHtml(homePage?.data.title ?? 'The HiChee Blog');
910
1011
function rewriteHomeHtml(body: string): string {
1112
const hrefPattern = /href=(["'])https?:\/\/blog\.hichee\.com([^"']*)\1/gi;
@@ -31,14 +32,36 @@ function rewriteInternalHref(pathValue: string): string | null {
3132
const withLeadingSlash = withoutQuery.startsWith('/') ? withoutQuery : `/${withoutQuery}`;
3233
return withLeadingSlash.endsWith('/') ? withLeadingSlash : `${withLeadingSlash}/`;
3334
}
35+
36+
function buildHomeShareHtml(title: string): string {
37+
const shareUrl = 'https://blog.hichee.com/';
38+
const linkUrl = encodeURIComponent(shareUrl);
39+
const linkName = encodeURIComponent(title);
40+
const escapedTitle = title.replace(/&/g, '&amp;').replace(/"/g, '&quot;');
41+
const channels = [
42+
{ channel: 'facebook', label: 'Facebook' },
43+
{ channel: 'twitter', label: 'Twitter' },
44+
{ channel: 'pinterest', label: 'Pinterest' },
45+
{ channel: 'whatsapp', label: 'WhatsApp' },
46+
{ channel: 'email', label: 'Email' }
47+
];
48+
49+
const socialLinks = channels
50+
.map(
51+
(item) =>
52+
`<a class="a2a_button_${item.channel}" href="https://www.addtoany.com/add_to/${item.channel}?linkurl=${linkUrl}&linkname=${linkName}" title="${item.label}" rel="nofollow noopener" target="_blank"></a>`
53+
)
54+
.join('');
55+
56+
return `<div class="addtoany_share_save_container addtoany_content addtoany_content_bottom"><div class="a2a_kit a2a_kit_size_32 addtoany_list" data-a2a-url="${shareUrl}" data-a2a-title="${escapedTitle}">${socialLinks}<a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share"></a></div></div>`;
57+
}
3458
---
3559

3660
<BaseLayout
3761
title="The HiChee Blog and Travel Guide"
3862
description="Insider travel tips and destination guides from HiChee."
3963
canonical="/"
4064
bodyClass="legacy-home home wp-theme-kadence wp-custom-logo"
41-
suppressFooter={true}
4265
>
4366
<Fragment slot="head">
4467
<link rel="stylesheet" href="/wp-legacy/wp-block-library.min.css" />
@@ -55,7 +78,10 @@ function rewriteInternalHref(pathValue: string): string | null {
5578

5679
{
5780
homePage ? (
58-
<article class="legacy-home-content" set:html={legacyHomeHtml} />
81+
<article class="legacy-home-content">
82+
<Fragment set:html={legacyHomeHtml} />
83+
<Fragment set:html={homeShareHtml} />
84+
</article>
5985
) : (
6086
<section class="listing-hero">
6187
<p class="eyebrow">Missing Source</p>

0 commit comments

Comments
 (0)