Skip to content

Commit 0976514

Browse files
committed
Cleanup
Remove unused code and update link rels
1 parent c8992bf commit 0976514

File tree

4 files changed

+13
-63
lines changed

4 files changed

+13
-63
lines changed

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Layout.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const Layout = ({ children }) => {
2727
<a
2828
target="_blank"
2929
href="https://ui.dev"
30+
rel="noopener"
3031
style={{
3132
boxShadow: "0 2px 0 0 rgba(255, 255, 255, 0.3)",
3233
lineHeight: 2,
@@ -86,7 +87,8 @@ export const Layout = ({ children }) => {
8687
<div className="level-item">
8788
<a
8889
target="_blank"
89-
href="https://twitter.com/gabe_ragland"
90+
href="https://twitter.com/uidotdev"
91+
rel="noreferrer"
9092
onClick={() => {
9193
analytics.track("clickFooterTwitter");
9294
}}
@@ -100,7 +102,8 @@ export const Layout = ({ children }) => {
100102
<div className="level-item">
101103
<a
102104
target="_blank"
103-
href="https://github.com/gragland/usehooks"
105+
href="https://github.com/uidotdev/usehooks"
106+
rel="noreferrer"
104107
onClick={() => {
105108
analytics.track("clickFooterGithub");
106109
}}
@@ -115,6 +118,7 @@ export const Layout = ({ children }) => {
115118
<a
116119
target="_blank"
117120
href="/rss.xml"
121+
rel="noopener"
118122
onClick={() => {
119123
analytics.track("clickFooterRss");
120124
}}
@@ -136,7 +140,8 @@ const GitHubLink = () => {
136140
<a
137141
className="is-hidden-mobile"
138142
target="blank"
139-
href="https://github.com/gragland/usehooks"
143+
rel="noreferrer"
144+
href="https://github.com/uidotdev/usehooks"
140145
onClick={() => {
141146
analytics.track("clickTopGithub");
142147
}}
@@ -181,15 +186,3 @@ const FooterLevel = styled("div").attrs({ className: "level" })`
181186
text-decoration: underline;
182187
}
183188
`;
184-
185-
const Bar = styled("div")`
186-
font-size: 20px;
187-
padding: 1rem;
188-
color: white;
189-
text-align: center;
190-
background-color: black;
191-
192-
> a:link {
193-
text-decoration: none;
194-
}
195-
`;

src/components/PostTemplate.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const PostTemplate = ({ content, frontmatter, slug, permalink }) => {
7171
<LinksLi key={i}>
7272
<a
7373
target={link.target || "_blank"}
74+
rel="noopener"
7475
href={link.url}
7576
onClick={() => {
7677
analytics.track("clickExtraLink");
@@ -113,7 +114,7 @@ const PostTemplate = ({ content, frontmatter, slug, permalink }) => {
113114
{frontmatter.sandbox && (
114115
<>
115116
<div className="level-item">
116-
<a target="_blank" href={frontmatter.sandbox}>
117+
<a target="_blank" rel="noreferrer" href={frontmatter.sandbox}>
117118
Open in CodeSandbox
118119
</a>
119120
</div>
@@ -123,7 +124,7 @@ const PostTemplate = ({ content, frontmatter, slug, permalink }) => {
123124
</>
124125
)}
125126
<div className="level-item">
126-
<a target="_blank" href={frontmatter.gist}>
127+
<a target="_blank" rel="noreferrer" href={frontmatter.gist}>
127128
Suggest a change
128129
</a>
129130
</div>

src/templates/index.js

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,12 @@ import Layout from "../components/Layout";
55
import PostTemplate from "../components/PostTemplate";
66

77
const IndexPage = ({ pageContext }) => {
8-
//const [search, setSearch] = useState("");
9-
// const [searchMatches, setSearchMatches] = useState([]);
10-
118
const { group, index, first, last, pageCount } = pageContext;
12-
const previousUrl = index - 1 == 1 ? "/" : `/page/${index - 1}`;
9+
const previousUrl = index - 1 === 1 ? "/" : `/page/${index - 1}`;
1310
const nextUrl = "/page/" + (index + 1).toString();
1411

1512
return (
1613
<Layout>
17-
{/*
18-
<Search
19-
value={search}
20-
onChange={value => setSearch({ search: value })}
21-
/>
22-
*/}
23-
2414
{group.map(({ node }) => (
2515
<PostTemplate
2616
key={node.id}
@@ -83,44 +73,9 @@ const IndexPage = ({ pageContext }) => {
8373
);
8474
})}
8575
</ul>
86-
{/*<span>{` Page ${index} of ${pageCount}`}</span>*/}
8776
</nav>
8877
</Layout>
8978
);
9079
};
9180

9281
export default IndexPage;
93-
94-
// Quicky and hacky search
95-
function searchPosts(posts, search) {
96-
// Store title matches for quick lookup
97-
let titles = {};
98-
99-
// Get all posts that have a matching title
100-
const filterPostsByTitle = posts.filter((post) => {
101-
const hook = post.node.frontmatter;
102-
const titleLowerCase = hook.title.toLowerCase();
103-
const doesInclude = titleLowerCase.includes(search.toLowerCase());
104-
if (doesInclude) {
105-
titles[titleLowerCase] = true;
106-
return true;
107-
} else {
108-
return false;
109-
}
110-
});
111-
112-
// Get all posts that have a matching description and DON'T match by title
113-
const filterPostsByDescription = posts.filter((post) => {
114-
const hook = post.node.frontmatter;
115-
const titleLowerCase = hook.title.toLowerCase();
116-
const description = post.node.html || "";
117-
return (
118-
!titles[titleLowerCase] &&
119-
description.toLowerCase().includes(search.toLowerCase())
120-
);
121-
});
122-
123-
// Add description matches to end of results
124-
const filteredPosts = filterPostsByTitle.concat(filterPostsByDescription);
125-
return filteredPosts;
126-
}

0 commit comments

Comments
 (0)