Skip to content

Commit f98008a

Browse files
committed
fix absolute url for Share component
1 parent 5bffd99 commit f98008a

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

docs/working-notes/todo3.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,5 +417,7 @@ fix share, just small gray icons
417417
use vertical margins and margin collapsing for all vertical spacings, no paddings, when in same parent
418418
remove tag-lg, fix button size on mobile
419419
alert component style
420+
improve lighthouse, accessibility, aria attrs
421+
2 prerendered paginations, 3 and 5 items
420422
```
421423

src/constants/routes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const ROUTES = {
99
EXPLORE: '/blog/explore/',
1010
EXPLORE_TAGS: '/blog/explore/tags/',
1111
EXPLORE_CATEGORIES: '/blog/explore/categories/',
12+
DESIGN: '/design/',
1213
/** maybe in future */
1314
DRAFTS: '/drafts/',
1415
_404: '/404/',

src/pages/blog/[slug].astro

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ import TagList from '@/components/TagList.astro';
1414
import { draftText } from '@/constants/data';
1515
import { IMAGE_SIZES } from '@/constants/image';
1616
import { ROUTES } from '@/constants/routes';
17+
import { CONFIG } from '@/config';
1718
import { getOpenGraphImagePath } from '@/libs/api/open-graph/image-path';
1819
1920
import type { Metadata } from '@/types/common';
2021
import type { Post } from '@/types/post';
2122
23+
const { SITE_URL } = CONFIG;
24+
2225
export async function getStaticPaths() {
2326
const posts: Post[] = await getAllPostsWithReadingTime();
2427
@@ -63,6 +66,12 @@ const postMetaProps = {
6366
updatedDate,
6467
};
6568
69+
const shareProps = {
70+
title,
71+
description,
72+
url: `${SITE_URL}${ROUTES.BLOG}${slug}`,
73+
};
74+
6675
// handle all metadata here
6776
const image = getOpenGraphImagePath(pathname);
6877
@@ -111,7 +120,7 @@ const metadata: Metadata = { title, description, image };
111120
<Fragment slot="after-content">
112121
<div class="flex justify-between items-start gap-6 flex-col md:flex-row b-h2-mb">
113122
<TagList tags={tags} size="md" />
114-
<Share {title} {description} url={`${ROUTES.BLOG}${slug}`} />
123+
<Share {...shareProps} />
115124
</div>
116125

117126
<Giscus class="b-h2-mt" />

src/pages/design/embeds.mdx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import { Tweet, Vimeo, LinkPreview } from 'astro-embed';
77
import YouTube from '../../components/YouTube.astro';
88
import Share from '../../components/Share.astro';
99

10+
import { ROUTES } from '../../constants/routes';
11+
import { CONFIG } from '../../config';
12+
13+
1014

1115
{/* for Twitter iframe */}
1216
<script async src="https://platform.twitter.com/widgets.js" />
@@ -17,8 +21,13 @@ back to [Index](/design)
1721

1822
### Social share
1923

20-
<Share />
24+
export const shareProps = {
25+
title: 'Embed page',
26+
description: 'Embed page description',
27+
url: `${CONFIG.SITE_URL}${ROUTES.DESIGN}embeds`,
28+
};
2129

30+
<Share {...shareProps} />
2231
---
2332

2433
### astro-embed

src/pages/projects/[slug].astro

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ import { getAllProjects } from '@/modules/project';
33
import Project from '@/layouts/Project.astro';
44
import Share from '@/components/Share.astro';
55
import { ROUTES } from '@/constants/routes';
6+
import { CONFIG } from '@/config';
67
import { getOpenGraphImagePath } from '@/libs/api/open-graph/image-path';
78
89
import type { Metadata } from '@/types/common';
910
11+
const { SITE_URL } = CONFIG;
12+
1013
export async function getStaticPaths() {
1114
const sortedProjects = await getAllProjects();
1215
@@ -27,10 +30,16 @@ const { title, description } = data;
2730
2831
const metadata: Metadata = { title, description, image };
2932
33+
const shareProps = {
34+
title,
35+
description,
36+
url: `${SITE_URL}${ROUTES.PROJECTS}${slug}`,
37+
};
38+
3039
const { Content } = await render();
3140
---
3241

3342
<Project {metadata}>
3443
<Content />
35-
<Share {title} {description} url={`${ROUTES.PROJECTS}${slug}`} />
44+
<Share {...shareProps} />
3645
</Project>

0 commit comments

Comments
 (0)