add header link icon
This commit is contained in:
+26
-2
@@ -3,6 +3,7 @@ import { writeFileSync } from 'fs'
|
||||
import readingTime from 'reading-time'
|
||||
import { slug } from 'github-slugger'
|
||||
import path from 'path'
|
||||
import { fromHtmlIsomorphic } from 'hast-util-from-html-isomorphic'
|
||||
// Remark packages
|
||||
import remarkGfm from 'remark-gfm'
|
||||
import remarkMath from 'remark-math'
|
||||
@@ -25,6 +26,19 @@ import { allCoreContent, sortPosts } from 'pliny/utils/contentlayer.js'
|
||||
const root = process.cwd()
|
||||
const isProduction = process.env.NODE_ENV === 'production'
|
||||
|
||||
// heroicon mini link
|
||||
const icon = fromHtmlIsomorphic(
|
||||
`
|
||||
<span class="content-header-link">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" className="w-5 h-5 linkicon">
|
||||
<path d="M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z" />
|
||||
<path d="M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z" />
|
||||
</svg>
|
||||
</span>
|
||||
`,
|
||||
{ fragment: true }
|
||||
)
|
||||
|
||||
const computedFields: ComputedFields = {
|
||||
readingTime: { type: 'json', resolve: (doc) => readingTime(doc.body.raw) },
|
||||
slug: {
|
||||
@@ -134,7 +148,6 @@ export default makeSource({
|
||||
mdx: {
|
||||
cwd: process.cwd(),
|
||||
remarkPlugins: [
|
||||
// @ts-ignore
|
||||
remarkExtractFrontmatter,
|
||||
remarkGfm,
|
||||
remarkCodeTitles,
|
||||
@@ -143,7 +156,18 @@ export default makeSource({
|
||||
],
|
||||
rehypePlugins: [
|
||||
rehypeSlug,
|
||||
rehypeAutolinkHeadings,
|
||||
[
|
||||
rehypeAutolinkHeadings,
|
||||
{
|
||||
behavior: 'prepend',
|
||||
headingProperties: {
|
||||
className: ['content-header'],
|
||||
tabIndex: '-1',
|
||||
dir: 'auto',
|
||||
},
|
||||
content: icon,
|
||||
},
|
||||
],
|
||||
rehypeKatex,
|
||||
[rehypeCitation, { path: path.join(root, 'data') }],
|
||||
[rehypePrismPlus, { defaultLanguage: 'js', ignoreMissing: true }],
|
||||
|
||||
Reference in New Issue
Block a user