Skip to content

Commit

Permalink
feat: 增加一些类名,便于进行自定义 CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
Mereithhh committed May 5, 2023
1 parent d8ebe73 commit 20d7075
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 34 deletions.
10 changes: 5 additions & 5 deletions packages/website/components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function ({
}) {
return (
<>
<footer className="text-center text-sm space-y-1 mt-8 md:mt-12 dark:text-dark">
<footer className="text-center text-sm space-y-1 mt-8 md:mt-12 dark:text-dark footer-icp-number">
{Boolean(ipcNumber) && (
<p className="">
ICP 编号:&nbsp;
Expand All @@ -37,7 +37,7 @@ export default function ({
</p>
)}
{Boolean(gaBeianNumber) && (
<p className="flex justify-center items-center">
<p className="flex justify-center items-center footer-gongan-beian">
公安备案:&nbsp;
{Boolean(gaBeianLogoUrl) && (
<ImageBox
Expand All @@ -57,7 +57,7 @@ export default function ({
</p>
)}
<RunningTime since={since}></RunningTime>
<p className="">
<p className="footer-powered-by-vanblog">
Powered By&nbsp;
<a
href="https://vanblog.mereith.com"
Expand All @@ -68,10 +68,10 @@ export default function ({
</a>
</p>

<p className="select-none">
<p className="select-none footer-copy-right">
© {new Date(since).getFullYear()} - {new Date().getFullYear()}
</p>
<p className="select-none">
<p className="select-none footer-viewer">
<Viewer></Viewer>
</p>
</footer>
Expand Down
4 changes: 2 additions & 2 deletions packages/website/components/LayoutBody/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ export default function (props: {
return (
<>
<div className="flex mx-auto justify-center">
<div className="flex-shrink flex-grow md:max-w-3xl xl:max-w-4xl w-full">
<div className="flex-shrink flex-grow md:max-w-3xl xl:max-w-4xl w-full vanblog-main">
{props.children}
</div>
<div
className={`hidden lg:block flex-shrink-0 flex-grow-0 ${
className={`hidden lg:block flex-shrink-0 flex-grow-0 vanblog-sider ${
Boolean(props.sideBar) ? "w-52" : ""
}`}
>
Expand Down
41 changes: 23 additions & 18 deletions packages/website/components/Markdown/codeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const codeBlockPlugin = () => (tree) => {
visit(tree, (node) => {
if (node.type === "element" && node.tagName === "pre") {
const oldChildren = JSON.parse(JSON.stringify(node.children));
const codeProperties = oldChildren.find((child: any) => child.tagName === "code").properties;
const codeProperties = oldChildren.find(
(child: any) => child.tagName === "code"
).properties;
let language = "";
if (codeProperties.className) {
for (const each of codeProperties.className) {
Expand All @@ -26,47 +28,50 @@ const codeBlockPlugin = () => (tree) => {
properties: {
class: "code-copy-btn",
},
children: []
}
children: [],
};
const languageTag = {
type: "element",
tagName: "span",
properties: {
class: "language-tag mr-1",
style: "line-height: 21px"
style: "line-height: 21px",
},
children: [
{
type: "text",
value: language
}
]
}
value: language,
},
],
};
// 上方右侧 header
const headerRight = {
type: "element",
tagName: "div",
properties: {
class: "header-right flex",
style: "color: #6f7177",

},
children: [
languageTag, codeCopyBtn
]
}
children: [languageTag, codeCopyBtn],
};
// 包裹的 div
const wrapperDiv = {
type: "element",
tagName: "div",
properties: {
class: "code-block-wrapper relative"
class: "code-block-wrapper relative",
},
children: [
headerRight, ...oldChildren
]
children: [headerRight, ...oldChildren],
};
node.children = [wrapperDiv];
}
if (node.type === "element" && node.tagName === "code") {
if (!node?.properties?.className?.includes("hljs")) {
node.properties.className = [
"code-inline",
...(node?.properties?.className || []),
];
}
node.children = [wrapperDiv]
}
});
};
Expand Down
12 changes: 9 additions & 3 deletions packages/website/components/NavBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ export default function (props: {
</div>
{props.headerLeftContent == "siteLogo" && (
<div className="hidden md:block transform translate-x-2">
<img alt="site logo" src={picUrl} width={52} height={52} className="" />
<img
alt="site logo"
src={picUrl}
width={52}
height={52}
className=""
/>
</div>
)}
</div>
Expand All @@ -108,7 +114,7 @@ export default function (props: {
</Link>
)}
{/* 第二个flex */}
<div className="flex justify-between h-full flex-grow ">
<div className="flex justify-between h-full flex-grow nav-content">
<div
style={{ transform: "translateX(30px)" }}
className="cursor-pointer md:hidden flex-grow text-center flex items-center justify-center select-none dark:text-dark"
Expand All @@ -122,7 +128,7 @@ export default function (props: {
return <Item key={m.id} item={m} />;
})}
</ul>
<div className="flex">
<div className="flex nav-action">
<div
onClick={() => {
setShowSearch(true);
Expand Down
10 changes: 4 additions & 6 deletions packages/website/components/PostCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ export default function (props: {
}, [props.type, props.content]);

return (
<div>
<div className="post-card-wrapper">
<div
style={{ position: "relative" }}
id="post-card"
className="overflow-hidden bg-white card-shadow py-4 px-1 sm:px-3 md:py-6 md:px-5 dark:bg-dark dark:nav-shadow-dark"
className="overflow-hidden post-card bg-white card-shadow py-4 px-1 sm:px-3 md:py-6 md:px-5 dark:bg-dark dark:nav-shadow-dark"
>
{props.top != 0 && <TopPinIcon></TopPinIcon>}
<Title
Expand Down Expand Up @@ -123,7 +123,7 @@ export default function (props: {
) : (
<>
{showToc && <TocMobile content={calContent} />}
<Markdown content={calContent}></Markdown>
<Markdown content={calContent}></Markdown>
</>
)}
</div>
Expand All @@ -134,9 +134,7 @@ export default function (props: {
href={`/post/${props.id}`}
target={getTarget(props.openArticleLinksInNewWindow)}
>
<div
className=" dark:bg-dark dark:hover:bg-dark-light dark:hover:text-dark-r dark:border-dark dark:text-dark hover:bg-gray-800 hover:text-gray-50 border-2 border-gray-800 text-sm md:text-base text-gray-700 px-2 py-1 transition-all rounded"
>
<div className=" dark:bg-dark dark:hover:bg-dark-light dark:hover:text-dark-r dark:border-dark dark:text-dark hover:bg-gray-800 hover:text-gray-50 border-2 border-gray-800 text-sm md:text-base text-gray-700 px-2 py-1 transition-all rounded">
阅读全文
</div>
</Link>
Expand Down

0 comments on commit 20d7075

Please sign in to comment.