Skip to content

Commit

Permalink
feat: use rehype-infer-description-meta to get excerpt
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Dec 8, 2022
1 parent ee44814 commit b72fbb5
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 25 deletions.
3 changes: 2 additions & 1 deletion showcase.json
Expand Up @@ -56,5 +56,6 @@
"henryq",
"duoyu",
"candinya",
"shang"
"shang",
"v1984"
]
2 changes: 1 addition & 1 deletion src/components/site/SiteHome.tsx
Expand Up @@ -81,7 +81,7 @@ export const SiteHome: React.FC<{
</span>
</div>
<div
className="xlog-post-excerpt mt-3 text-zinc-500"
className="xlog-post-excerpt mt-3 text-zinc-500 line-clamp-2"
style={{
wordBreak: "break-word",
}}
Expand Down
6 changes: 3 additions & 3 deletions src/markdown/index.ts
Expand Up @@ -9,7 +9,6 @@ import rehypeRaw from "rehype-raw"
import { refractor } from "refractor"
import rehypePrismGenerator from "rehype-prism-plus/generator"
import { rehypeImage } from "./rehype-image"
import { remarkExcerpt } from "./remark-excerpt"
import { rehypeTable } from "./rehype-table"
import { remarkCallout } from "./remark-callout"
import { rehypeExternalLink } from "./rehyper-external-link"
Expand All @@ -30,6 +29,7 @@ import type { Root } from "hast"
import { Mention } from "~/components/ui/Mention"
import remarkMath from "remark-math"
import rehypeKatex from "rehype-katex"
import rehypeInferDescriptionMeta from "rehype-infer-description-meta"

export type MarkdownEnv = {
excerpt: string
Expand Down Expand Up @@ -88,7 +88,6 @@ export const renderPageContent = (
env.toc = toc(tree, { tight: true, ordered: true })
})
.use(remarkGfm, {})
.use(remarkExcerpt, { env })
.use(remarkCallout)
.use(remarkDirective)
.use(remarkDirectiveRehype)
Expand All @@ -107,6 +106,7 @@ export const renderPageContent = (
.use(rehypeTable)
.use(rehypeExternalLink)
.use(rehypeWrapCode)
.use(rehypeInferDescriptionMeta)
.use(rehypeSlug)
.use(rehypeAutolinkHeadings, {
properties: {
Expand Down Expand Up @@ -155,7 +155,7 @@ export const renderPageContent = (
return {
contentHTML,
element: result?.result,
excerpt: env.excerpt,
excerpt: result?.data.meta.description,
frontMatter: env.frontMatter,
cover: env.cover,
toc: env.toc,
Expand Down
19 changes: 0 additions & 19 deletions src/markdown/remark-excerpt.ts

This file was deleted.

2 changes: 1 addition & 1 deletion tailwind.config.js
Expand Up @@ -22,5 +22,5 @@ module.exports = {
},
},
variants: {},
plugins: [],
plugins: [require("@tailwindcss/line-clamp")],
}

0 comments on commit b72fbb5

Please sign in to comment.