Skip to content

Commit 904bb11

Browse files
authored
feat: implement site's base open graph data (#50)
This pull request implements the default web app's open-graph data, configuring all `meta` tags for open-graph consumptions on all site. ### Changes Made - Modified `base.astro` layout to accept new props with some default value set... see below... - `ogImageUrl` - an open-graph image url slated to be configured per page depending on its content but set to use a default image as value incases where it is not provided at integration of the `base.astro` layout - `description` - an excerpt of a page's content with a default of drawn from the `SITE_META_DESCRIPTION` which is used as value when value isn't provided at integration - `subtitle` - used as second descriptive text in site's title with default value - Added a static `og.png` image to `public` directory used as default value for `ogImageUrl` prop - Implemented all required `meta` tags for open-graph and twitter cards specific ones - Added 2 new constants - `SITE_META_DESCRIPTION` - a string used as default value for the `description` prop on the `base.astro` layout. - `SITE_META_KEYWORDS` - an list of keywords integrated on the `meta:keywords` tag - Modified site's favicon to temporarily use a book icon svg, replacing the default `astrojs` logo ### Screencast [screencast-vercel.com-2024.04.20-12_35_42.webm](https://github.com/babblebey/jargons.dev/assets/25631971/2cf5f6a0-412b-4171-a370-b6ec363fc300) 📖
1 parent 5569610 commit 904bb11

4 files changed

Lines changed: 49 additions & 6 deletions

File tree

constants.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
export const PROJECT_REPO_DETAILS = {
22
repoFullname: import.meta.env.PUBLIC_PROJECT_REPO,
33
repoMainBranchRef: import.meta.env.PUBLIC_PROJECT_REPO_BRANCH_REF
4-
}
4+
}
5+
6+
export const SITE_META_DESCRIPTION = "A community-driven dictionary that simplifies software, engineering and tech terms for all levels. Curated by contributors, jargons.dev offers clear, easy-to-understand definitions."
7+
8+
export const SITE_META_KEYWORDS = [
9+
"dev jargon",
10+
"dev jargons",
11+
"software engineering terms",
12+
"web dev terms",
13+
"software jargons",
14+
"software terms",
15+
"developer jargons",
16+
"web jargons",
17+
"web development terms",
18+
"software development jargons",
19+
"software engineering dictionary",
20+
"dev dictionary",
21+
"developer dictionary",
22+
"software development dictionary",
23+
];

public/favicon.svg

Lines changed: 3 additions & 3 deletions
Loading

public/og.png

19.2 KB
Loading

src/layouts/base.astro

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@
22
import "@fontsource/inter";
33
import "@fontsource/ibm-plex-mono";
44
import "../base.css";
5+
import { SITE_META_KEYWORDS, SITE_META_DESCRIPTION } from "../../constants.js";
56
6-
const { pageTitle, class:list } = Astro.props;
7+
const { props, url } = Astro;
8+
const {
9+
pageTitle,
10+
class:list,
11+
ogImageUrl = `${url.origin}/og.png`,
12+
description = SITE_META_DESCRIPTION,
13+
subtitle = "Developer Jargons"
14+
} = props;
715
---
816

917
<html lang="en">
@@ -12,7 +20,23 @@ const { pageTitle, class:list } = Astro.props;
1220
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
1321
<meta name="viewport" content="width=device-width" />
1422
<meta name="generator" content={Astro.generator} />
15-
<title>{ pageTitle } - Developer Jargons</title>
23+
<meta name="description" content={description} />
24+
<meta name="keyword" content={SITE_META_KEYWORDS.join(",")} />
25+
26+
<meta property="og:url" content={url.href}>
27+
<meta property="og:type" content="website">
28+
<meta property="og:title" content={`${ pageTitle } - ${subtitle}`}>
29+
<meta property="og:description" content={description}>
30+
<meta property="og:image" content={ogImageUrl}>
31+
32+
<meta name="twitter:card" content="summary_large_image">
33+
<meta property="twitter:domain" content={url.host}>
34+
<meta property="twitter:url" content={url.href}>
35+
<meta name="twitter:title" content={`${ pageTitle } - ${subtitle}`}>
36+
<meta name="twitter:description" content={description}>
37+
<meta name="twitter:image" content={ogImageUrl}>
38+
39+
<title>{ pageTitle } - {subtitle}</title>
1640
</head>
1741
<body class={list}>
1842
<slot />

0 commit comments

Comments
 (0)