@@ -9,20 +9,22 @@ import { ROUTES } from '@/constants/routes';
9
9
import { CONFIG } from ' @/config' ;
10
10
import { handleTitle } from ' @/utils/metadata' ;
11
11
import { filterUndefined } from ' @/utils/objects' ;
12
- import { trimHttpProtocol } from ' @/utils/strings' ;
13
12
14
13
import type { Metadata } from ' @/types/common' ;
15
14
16
- const { SITE_URL } = CONFIG ;
17
- const domain = trimHttpProtocol (SITE_URL );
15
+ const { AUTHOR_NAME } = CONFIG ;
18
16
19
17
export interface BaseHeadProps {
20
18
metadata: Metadata ;
21
19
}
22
20
23
21
// set defualt metadata in this component
24
22
const { metadata } = Astro .props as BaseHeadProps ;
25
- const { url : baseUrl } = Astro ; // object
23
+
24
+ // site: SITE_URL var + '/'
25
+ // url: full page url, cannonical url, per page
26
+ const { url } = Astro ; // objects
27
+ const { host } = url ;
26
28
27
29
const handledMetadata = handleTitle (metadata );
28
30
@@ -31,7 +33,7 @@ const mergedMetadata: Required<Metadata> = { ...DEFAULT_METADATA, ...filteredMet
31
33
32
34
const { title, description, image } = mergedMetadata ;
33
35
34
- const ogImageUrl = new URL (image , baseUrl );
36
+ const ogImageUrl = new URL (image , url );
35
37
---
36
38
37
39
<head >
@@ -41,60 +43,60 @@ const ogImageUrl = new URL(image, baseUrl);
41
43
42
44
<meta name =" theme-color" content =" #c1ddf9" media =" (prefers-color-scheme: light)" />
43
45
<meta name =" theme-color" content =" #0f172a" media =" (prefers-color-scheme: dark)" />
46
+
47
+ { /* Links */ }
48
+ { /* Root-Relative URL (Starts with /): */ }
49
+ <link rel =" canonical" href ={ url } />
44
50
<link
45
51
rel =" apple-touch-icon"
46
52
sizes =" 180x180"
47
- href ={ ` ${SITE_URL }${ ROUTES .STATIC .FAVICONS }apple-touch-icon.png ` }
53
+ href ={ ` ${ROUTES .STATIC .FAVICONS }apple-touch-icon.png ` }
48
54
/>
49
55
<link
50
56
rel =" icon"
51
57
type =" image/png"
52
58
sizes =" 32x32"
53
- href ={ ` ${SITE_URL }${ ROUTES .STATIC .FAVICONS }favicon-32x32.png ` }
59
+ href ={ ` ${ROUTES .STATIC .FAVICONS }favicon-32x32.png ` }
54
60
/>
55
61
<link
56
62
rel =" icon"
57
63
type =" image/png"
58
64
sizes =" 16x16"
59
- href ={ ` ${SITE_URL }${ ROUTES .STATIC .FAVICONS }favicon-16x16.png ` }
65
+ href ={ ` ${ROUTES .STATIC .FAVICONS }favicon-16x16.png ` }
60
66
/>
61
- <link rel =" manifest" href ={ ` ${ SITE_URL } /manifest.json` } />
67
+ <link rel =" manifest" href =" /manifest.json" />
62
68
63
69
{ /* Primary Meta Tags */ }
64
70
<title >{ title } </title >
65
71
<meta name =" title" content ={ title } />
66
72
<meta name =" description" content ={ description } />
73
+ <meta name =" author" content ={ AUTHOR_NAME } />
67
74
68
75
{ /* Feeds */ }
69
76
<link
70
77
rel =" alternate"
71
78
type =" application/rss+xml"
72
- title ={ ` RSS feed for ${domain } ` }
73
- href ={ ` ${SITE_URL }${ ROUTES .API .FEED_RSS } ` }
79
+ title ={ ` RSS feed for ${host } ` }
80
+ href ={ ` ${ROUTES .API .FEED_RSS } ` }
74
81
/>
75
82
<link
76
83
rel =" alternate"
77
84
type =" application/json"
78
- title ={ ` JSON feed for ${domain } ` }
79
- href ={ ` ${SITE_URL }${ROUTES .API .FEED_JSON } ` }
80
- />
81
- <link
82
- rel =" sitemap"
83
- type =" application/xml"
84
- title =" Sitemap"
85
- href ={ ` ${SITE_URL }${ROUTES .STATIC .SITEMAP } ` }
85
+ title ={ ` JSON feed for ${host } ` }
86
+ href ={ ` ${ROUTES .API .FEED_JSON } ` }
86
87
/>
88
+ <link rel =" sitemap" type =" application/xml" title =" Sitemap" href ={ ` ${ROUTES .STATIC .SITEMAP } ` } />
87
89
88
90
{ /* Open Graph / Facebook */ }
89
91
<meta property =" og:type" content =" website" />
90
- <meta property =" og:url" content ={ baseUrl } />
92
+ <meta property =" og:url" content ={ url } />
91
93
<meta property =" og:title" content ={ title } />
92
94
<meta property =" og:description" content ={ description } />
93
95
<meta property =" og:image" content ={ ogImageUrl } />
94
96
95
97
{ /* Twitter */ }
96
98
<meta property =" twitter:card" content =" summary" />
97
- <meta property =" twitter:url" content ={ baseUrl } />
99
+ <meta property =" twitter:url" content ={ url } />
98
100
<meta property =" twitter:title" content ={ title } />
99
101
<meta property =" twitter:description" content ={ description } />
100
102
<meta property =" twitter:image" content ={ ogImageUrl } />
@@ -106,7 +108,7 @@ const ogImageUrl = new URL(image, baseUrl);
106
108
<script src="set-url-here" crossorigin="anonymous"></script>
107
109
-->
108
110
109
- <ViewTransitions fallback =" animate " />
111
+ <ViewTransitions fallback =" none " />
110
112
111
113
<!--
112
114
<style>
0 commit comments