|
@@ -1,28 +1,49 @@
|
1
|
1
|
import React from "react"
|
2
|
|
-import PropTypes from "prop-types"
|
|
2
|
+// import PropTypes from "prop-types"
|
3
|
3
|
import { Helmet } from "react-helmet"
|
4
|
4
|
import { useLocation } from "@reach/router"
|
5
|
5
|
import { useStaticQuery, graphql } from "gatsby"
|
6
|
|
-const SEO = ({ title, description, image, article }) => {
|
7
|
|
- const { pathname } = useLocation()
|
8
|
|
- const { site } = useStaticQuery(query)
|
|
6
|
+const SEO = () => {
|
9
|
7
|
const {
|
10
|
|
- defaultTitle,
|
11
|
|
- titleTemplate,
|
12
|
|
- defaultDescription,
|
13
|
|
- siteUrl,
|
14
|
|
- defaultImage,
|
15
|
|
- twitterUsername,
|
16
|
|
- } = site.siteMetadata
|
17
|
|
- const seo = {
|
18
|
|
- title: title || defaultTitle,
|
19
|
|
- description: description || defaultDescription,
|
20
|
|
- image: `${siteUrl}${image || defaultImage}`,
|
21
|
|
- url: `${siteUrl}${pathname}`,
|
|
8
|
+ allPostsYaml: { edges },
|
|
9
|
+ } = useStaticQuery(query)
|
|
10
|
+ const { pathname: location } = useLocation()
|
|
11
|
+
|
|
12
|
+ let snippets = location.split("/").filter(a => !!a)
|
|
13
|
+
|
|
14
|
+ if (snippets[0] === "blog") {
|
|
15
|
+ const posts = edges.map(({ node }) => node)
|
|
16
|
+ const post = posts.find(({ url }) => url === snippets[1])
|
|
17
|
+
|
|
18
|
+ if (post) {
|
|
19
|
+ snippets = ["blog", post.title]
|
|
20
|
+ }
|
22
|
21
|
}
|
|
22
|
+
|
|
23
|
+ const title = [...snippets.reverse(), "mrkvon"].join(" :: ")
|
|
24
|
+ const description =
|
|
25
|
+ "one more human has a homepage: freedom, sharing, coding, music"
|
|
26
|
+
|
23
|
27
|
return (
|
24
|
|
- <Helmet title={seo.title} titleTemplate={titleTemplate}>
|
25
|
|
- <meta name="description" content={seo.description} />
|
|
28
|
+ <Helmet title={title}>
|
|
29
|
+ <meta name="description" content="mrkvon homepage" />
|
|
30
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
31
|
+ <meta property="og:type" content="website" />
|
|
32
|
+ <meta property="og:title" content={title} />
|
|
33
|
+ <meta property="og:url" content="https://mrkvon.org" />
|
|
34
|
+ <meta
|
|
35
|
+ property="og:description"
|
|
36
|
+ content="one more human has a homepage: freedom, sharing, coding, music"
|
|
37
|
+ />
|
|
38
|
+ <meta name="twitter:title" content={title} />}
|
|
39
|
+ <meta name="twitter:description" content={description} />
|
|
40
|
+ <link
|
|
41
|
+ rel="meta"
|
|
42
|
+ type="text/turtle"
|
|
43
|
+ title="FOAF"
|
|
44
|
+ href="https://data.mrkvon.org/foaf.ttl"
|
|
45
|
+ />
|
|
46
|
+ {/*
|
26
|
47
|
<meta name="image" content={seo.image} />
|
27
|
48
|
{seo.url && <meta property="og:url" content={seo.url} />}
|
28
|
49
|
{(article ? true : null) && <meta property="og:type" content="article" />}
|
|
@@ -39,33 +60,25 @@ const SEO = ({ title, description, image, article }) => {
|
39
|
60
|
{seo.description && (
|
40
|
61
|
<meta name="twitter:description" content={seo.description} />
|
41
|
62
|
)}
|
42
|
|
- {seo.image && <meta name="twitter:image" content={seo.image} />}
|
|
63
|
+ {seo.image && <meta name="twitter:image" content={seo.image} />*/}
|
43
|
64
|
</Helmet>
|
44
|
65
|
)
|
45
|
66
|
}
|
46
|
67
|
export default SEO
|
47
|
|
-SEO.propTypes = {
|
48
|
|
- title: PropTypes.string,
|
49
|
|
- description: PropTypes.string,
|
50
|
|
- image: PropTypes.string,
|
51
|
|
- article: PropTypes.bool,
|
52
|
|
-}
|
53
|
|
-SEO.defaultProps = {
|
54
|
|
- title: null,
|
55
|
|
- description: null,
|
56
|
|
- image: null,
|
57
|
|
- article: false,
|
58
|
|
-}
|
|
68
|
+
|
59
|
69
|
const query = graphql`
|
60
|
|
- query SEO {
|
|
70
|
+ query SEOQuery {
|
61
|
71
|
site {
|
62
|
72
|
siteMetadata {
|
63
|
|
- defaultTitle: title
|
64
|
|
- titleTemplate
|
65
|
|
- defaultDescription: description
|
66
|
|
- siteUrl: url
|
67
|
|
- defaultImage: image
|
68
|
|
- twitterUsername
|
|
73
|
+ url
|
|
74
|
+ }
|
|
75
|
+ }
|
|
76
|
+ allPostsYaml {
|
|
77
|
+ edges {
|
|
78
|
+ node {
|
|
79
|
+ title
|
|
80
|
+ url
|
|
81
|
+ }
|
69
|
82
|
}
|
70
|
83
|
}
|
71
|
84
|
}
|