Skip to content

Commit 95ace5c

Browse files
committed
Remove unrelated files from PR
1 parent 649b156 commit 95ace5c

File tree

5 files changed

+43
-13
lines changed

5 files changed

+43
-13
lines changed

src/components/Page/Page.jsx

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export default function Page(props) {
4444
}, [props.content]);
4545

4646
const { hash, pathname } = useLocation();
47+
const isBlogIndex = pathname === "/blog/";
4748

4849
useEffect(() => {
4950
let observer;
@@ -52,13 +53,15 @@ export default function Page(props) {
5253
const target = document.querySelector("#md-content");
5354
// two cases here
5455
// 1. server side rendered page, so hash target is already there
55-
if (document.querySelector(hash)) {
56-
document.querySelector(hash).scrollIntoView();
56+
// Note: Why this change because we use getElementById instead of querySelector(hash) here because
57+
// CSS selectors cannot start with a digit (e.g. #11-in-scope is invalid)
58+
if (document.getElementById(hash.slice(1))) {
59+
document.getElementById(hash.slice(1)).scrollIntoView();
5760
} else {
5861
// 2. dynamic loaded content
5962
// we need to observe the dom change to tell if hash exists
6063
observer = new MutationObserver(() => {
61-
const element = document.querySelector(hash);
64+
const element = document.getElementById(hash.slice(1));
6265
if (element) {
6366
element.scrollIntoView();
6467
}
@@ -99,9 +102,12 @@ export default function Page(props) {
99102
);
100103
}
101104
return (
102-
<section className="page">
105+
<main id="main-content" className="page">
103106
<Markdown>
104107
<h1>{title}</h1>
108+
{rest.date && pathname.startsWith("/blog/") && !isBlogIndex && (
109+
<div className="blog-post-date">{rest.date}</div>
110+
)}
105111

106112
{rest.thirdParty ? (
107113
<div className="italic my-[20px]">
@@ -114,6 +120,27 @@ export default function Page(props) {
114120

115121
<div id="md-content">{contentRender}</div>
116122

123+
{rest.url === "/blog/" && (
124+
<div className="blog-list">
125+
{(props.pages || [])
126+
.filter((post) => post.url !== "/blog/")
127+
.map((post) => (
128+
<div key={post.url} className="blog-post-item">
129+
<h2>
130+
<Link to={post.url}>{post.title}</Link>
131+
</h2>
132+
{post.date && (
133+
<div className="blog-post-date">{post.date}</div>
134+
)}
135+
<p>{post.teaser}</p>
136+
<Link to={post.url} className="read-more">
137+
Read More &rarr;
138+
</Link>
139+
</div>
140+
))}
141+
</div>
142+
)}
143+
117144
{loadRelated && (
118145
<div className="print:hidden">
119146
<h2>Further Reading</h2>
@@ -129,7 +156,7 @@ export default function Page(props) {
129156

130157
<PageLinks page={rest} />
131158

132-
{(previous || next) && (
159+
{!isBlogIndex && (previous || next) && (
133160
<AdjacentPages previous={previous} next={next} />
134161
)}
135162

@@ -143,7 +170,7 @@ export default function Page(props) {
143170
</div>
144171
)}
145172
</Markdown>
146-
</section>
173+
</main>
147174
);
148175
}
149176

@@ -153,13 +180,12 @@ Page.propTypes = {
153180
related: PropTypes.array,
154181
previous: PropTypes.object,
155182
next: PropTypes.object,
183+
pages: PropTypes.array,
156184
content: PropTypes.oneOfType([
157-
PropTypes.string,
158-
PropTypes.func,
159185
PropTypes.shape({
160186
// eslint-disable-next-line unicorn/no-thenable
161187
then: PropTypes.func.isRequired,
162-
default: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
188+
default: PropTypes.string,
163189
}),
164190
]),
165191
};

src/components/Sidebar/Sidebar.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ export default function Sidebar({ className = "", pages, currentPage }) {
3131
<nav className={`sidebar ${className}`}>
3232
<div className="sidebar__inner">
3333
<div className="relative z-0 bg-white dark:bg-gray-100 ">
34+
<label htmlFor="docs-version" className="sr-only">
35+
Select webpack version
36+
</label>
3437
<select
38+
id="docs-version"
3539
className="text-gray-600 text-14 px-5 py-5 appearance-none box-border border border-gray-200 border-solid flex-col flex w-full rounded-none bg-transparent bg-none"
3640
value={version}
3741
onChange={(event) => {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`customize blockquote should transform W> into aside of warning 1`] = `
4-
"<aside class="warning"><h6 class="warning__prefix">warning</h6><p>hello world</p></aside>
4+
"<aside class="warning"><p class="warning__prefix">warning</p><p>hello world</p></aside>
55
"
66
`;

src/remark-plugins/remark-custom-asides/index.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ export default function remarkCustomAsides(
3737
// remove custom characters from paragraph
3838
node.children = [
3939
{
40-
type: "heading",
41-
depth: 6,
40+
type: "paragraph",
4241
data: {
4342
// see https://github.com/syntax-tree/mdast-util-to-hast#hname
4443
// add a className to heading
44+
hName: "p",
4545
hProperties: {
4646
className: `${className}__prefix`,
4747
},

src/remark-plugins/remark-custom-asides/index.test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ W> hello world
2020
(err, { value: contents }) => {
2121
expect(err).toBeUndefined();
2222
expect(contents).toContain('<aside class="warning"');
23-
expect(contents).toContain('<h6 class="warning__prefix"');
23+
expect(contents).toContain('<p class="warning__prefix"');
2424
expect(contents).toContain("warning");
2525
expect(contents).toMatchSnapshot();
2626
},

0 commit comments

Comments
 (0)