Skip to content

Commit

Permalink
Merge pull request #70 from keploy/seo-meta-desc
Browse files Browse the repository at this point in the history
feat: meta tags for blogs
  • Loading branch information
khareyash05 authored Dec 10, 2024
2 parents 44248be + 96819db commit b6991b5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
12 changes: 12 additions & 0 deletions lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ export async function getAllPostsForTechnology(preview) {
}
}
}
seo {
metaDesc
title
}
}
}
}
Expand Down Expand Up @@ -355,6 +359,10 @@ export async function getAllPostsForCommunity(preview) {
}
}
}
seo {
metaDesc
title
}
}
}
pageInfo {
Expand Down Expand Up @@ -560,6 +568,10 @@ export async function getPostAndMorePosts(slug, preview, previewData) {
}
}
}
seo{
metaDesc
title
}
}
query PostBySlug($id: ID!, $idType: PostIdType!) {
Expand Down
7 changes: 3 additions & 4 deletions pages/community/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export default function Post({ post, posts, reviewAuthorDetails, preview }) {
if (post && post.content) {

const content = post.content;

const avatarDivMatch = content.match(
/<div[^>]*class="pp-author-boxes-avatar"[^>]*>\s*<img[^>]*src='([^']*)'[^>]*\/?>/
);
Expand All @@ -117,7 +116,7 @@ export default function Post({ post, posts, reviewAuthorDetails, preview }) {

// Match the <p> with class pp-author-boxes-description and extract its content
const authorDescriptionMatch = content.match(
/<p[^>]*class="pp-author-boxes-description multiple-authors-description"[^>]*>(.*?)<\/p>/s
/<p[^>]*class="pp-author-boxes-description multiple-authors-description"[^>]*>(.*?)<\/p>/
);

// Apply table responsive wrapper
Expand Down Expand Up @@ -146,8 +145,8 @@ export default function Post({ post, posts, reviewAuthorDetails, preview }) {
<Layout
preview={preview}
featuredImage={post?.featuredImage?.node?.sourceUrl || ""}
Title={post?.title || "Loading..."}
Description={`Blog About ${post?.title}`}
Title={post?.seo.title || "Loading..."}
Description={`${post?.seo.metaDesc || "Blog About " + `${post?.title}`}`}
>
<Header readProgress={readProgress} />
<Container>
Expand Down
6 changes: 3 additions & 3 deletions pages/technology/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default function Post({ post, posts, reviewAuthorDetails, preview }) {

// Match the <p> with class pp-author-boxes-description and extract its content
const authorDescriptionMatch = content.match(
/<p[^>]*class="pp-author-boxes-description multiple-authors-description"[^>]*>(.*?)<\/p>/s
/<p[^>]*class="pp-author-boxes-description multiple-authors-description"[^>]*>(.*?)<\/p>/
);

if (
Expand All @@ -135,8 +135,8 @@ export default function Post({ post, posts, reviewAuthorDetails, preview }) {
<Layout
preview={preview}
featuredImage={post?.featuredImage?.node?.sourceUrl || ""}
Title={post?.title || "Loading..."}
Description={`Blog About ${post?.title || "the Article"}`}
Title={post?.seo.title || "Loading..."}
Description={`${post?.seo.metaDesc || "Blog About " + `${post?.title}`}`}
>
<Header readProgress={readProgress} />
<Container>
Expand Down

0 comments on commit b6991b5

Please sign in to comment.