Skip to content

Commit cf96d75

Browse files
committed
Updated next, created robots and sitemap
1 parent 5688e42 commit cf96d75

File tree

7 files changed

+2488
-8260
lines changed

7 files changed

+2488
-8260
lines changed

components/article/Comments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { DiscussionEmbed } from 'disqus-react'
33

44
export default function Comments({ params }) {
55
return (
6-
<Footer>
6+
<Footer className="comments">
77
<DiscussionEmbed
88
shortname='youknowwhatblog'
99
config={

components/article/Markdown.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
import ReactMarkdown from 'react-markdown'
22
import styled from 'styled-components'
3+
import { useEffect, useState } from 'react'
34

45
import ProgressiveImage from './markdown/ProgressiveImage'
56

67
export default function Markdown({ data }) {
8+
const [ headings, setHeadings ] = useState([])
9+
10+
useEffect(() => {
11+
const hTagsCollection = document.querySelectorAll('h2, h3, h4, h5, h6')
12+
const hTagsArr = [].slice.call(hTagsCollection)
13+
console.log(hTagsCollection, hTagsArr)
14+
setHeadings(hTagsArr)
15+
16+
if (hTagsArr.length !== 0) {
17+
hTagsArr.map(el => el.setAttribute('id', el.textContent))
18+
}
19+
},[])
20+
721
return (
822
<>
923
<Header>
@@ -26,6 +40,21 @@ export default function Markdown({ data }) {
2640
/>
2741
<figcaption><em>{data.image[0].caption}</em></figcaption>
2842
</Figure>
43+
{
44+
headings.length === 0 ? null :
45+
<Nav className="contents">
46+
<p>Contents</p>
47+
<ul>
48+
{
49+
headings.map(li =>
50+
<li className={li.nodeName} key={li.textContent}>
51+
<a href={`#${li.textContent}`}>{li.textContent}</a>
52+
</li>
53+
)
54+
}
55+
</ul>
56+
</Nav>
57+
}
2958
<ReactMarkdown
3059
source={data.content}
3160
escapeHtml={false}
@@ -60,3 +89,29 @@ const Figure = styled.figure`
6089
text-align: center;
6190
}
6291
`
92+
93+
const Nav = styled.nav`
94+
border: 2px solid black;
95+
border-radius: 15px;
96+
padding: 1em;
97+
margin-top: 1em;
98+
> p {
99+
margin-top: 0;
100+
}
101+
> ul {
102+
list-style-type: none;
103+
padding-left: 1em;
104+
> .H3 {
105+
padding-left: .5em;
106+
}
107+
> .H4 {
108+
padding-left: 1em;
109+
}
110+
> .H5 {
111+
padding-left: 1.5em;
112+
}
113+
> .H6 {
114+
padding-left: 2em;
115+
}
116+
}
117+
`

next-sitemap.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
siteUrl: 'https://next-js-strapi-blog.vercel.app',
3+
sitemapSize: 50000,
4+
exclude: ['/search'],
5+
generateRobotsTxt: true,
6+
robotsTxtOptions: {
7+
policies: [
8+
{
9+
userAgent: 'Googlebot-Image',
10+
disallow: '/'
11+
},
12+
{
13+
userAgent: '*',
14+
disallow: '/search'
15+
},
16+
{
17+
userAgent: '*',
18+
allow: '/'
19+
}
20+
]
21+
}
22+
}

0 commit comments

Comments
 (0)