fix: external links

This commit is contained in:
enscribe 2024-10-06 21:52:40 -07:00
parent e3e29ae66e
commit dc05cb25a6
No known key found for this signature in database
GPG key ID: 9BBD5C4114E25322
5 changed files with 43 additions and 5 deletions

View file

@ -10,6 +10,7 @@ import {
} from '@shikijs/transformers' } from '@shikijs/transformers'
import { defineConfig } from 'astro/config' import { defineConfig } from 'astro/config'
import rehypeKatex from 'rehype-katex' import rehypeKatex from 'rehype-katex'
import rehypeExternalLinks from 'rehype-external-links'
import rehypePrettyCode from 'rehype-pretty-code' import rehypePrettyCode from 'rehype-pretty-code'
import remarkEmoji from 'remark-emoji' import remarkEmoji from 'remark-emoji'
import remarkMath from 'remark-math' import remarkMath from 'remark-math'
@ -33,6 +34,13 @@ export default defineConfig({
markdown: { markdown: {
syntaxHighlight: false, syntaxHighlight: false,
rehypePlugins: [ rehypePlugins: [
[
rehypeExternalLinks,
{
target: '_blank',
rel: ['nofollow', 'noreferrer', 'noopener'],
},
],
rehypeHeadingIds, rehypeHeadingIds,
rehypeKatex, rehypeKatex,
// @ts-expect-error // @ts-expect-error

33
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "astro-erudite", "name": "astro-erudite",
"version": "1.1.6", "version": "1.1.7",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "astro-erudite", "name": "astro-erudite",
"version": "1.1.6", "version": "1.1.7",
"dependencies": { "dependencies": {
"@astrojs/check": "^0.7.0", "@astrojs/check": "^0.7.0",
"@astrojs/markdown-remark": "^5.2.0", "@astrojs/markdown-remark": "^5.2.0",
@ -35,6 +35,7 @@
"lucide-react": "^0.441.0", "lucide-react": "^0.441.0",
"react": "^18.3.1", "react": "^18.3.1",
"react-dom": "^18.3.1", "react-dom": "^18.3.1",
"rehype-external-links": "^3.0.0",
"rehype-katex": "^7.0.0", "rehype-katex": "^7.0.0",
"rehype-pretty-code": "^0.14.0", "rehype-pretty-code": "^0.14.0",
"remark-emoji": "^5.0.1", "remark-emoji": "^5.0.1",
@ -5918,6 +5919,17 @@
"loose-envify": "^1.0.0" "loose-envify": "^1.0.0"
} }
}, },
"node_modules/is-absolute-url": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/is-absolute-url/-/is-absolute-url-4.0.1.tgz",
"integrity": "sha512-/51/TKE88Lmm7Gc4/8btclNXWS+g50wXhYJq8HWIBAGUBnoAdRu1aXeh364t/O7wXDAcTJDP8PNuNKWUDWie+A==",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/is-alphabetical": { "node_modules/is-alphabetical": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz", "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz",
@ -8900,6 +8912,23 @@
"url": "https://opencollective.com/unified" "url": "https://opencollective.com/unified"
} }
}, },
"node_modules/rehype-external-links": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/rehype-external-links/-/rehype-external-links-3.0.0.tgz",
"integrity": "sha512-yp+e5N9V3C6bwBeAC4n796kc86M4gJCdlVhiMTxIrJG5UHDMh+PJANf9heqORJbt1nrCbDwIlAZKjANIaVBbvw==",
"dependencies": {
"@types/hast": "^3.0.0",
"@ungap/structured-clone": "^1.0.0",
"hast-util-is-element": "^3.0.0",
"is-absolute-url": "^4.0.0",
"space-separated-tokens": "^2.0.0",
"unist-util-visit": "^5.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/rehype-katex": { "node_modules/rehype-katex": {
"version": "7.0.0", "version": "7.0.0",
"resolved": "https://registry.npmjs.org/rehype-katex/-/rehype-katex-7.0.0.tgz", "resolved": "https://registry.npmjs.org/rehype-katex/-/rehype-katex-7.0.0.tgz",

View file

@ -1,7 +1,7 @@
{ {
"name": "astro-erudite", "name": "astro-erudite",
"type": "module", "type": "module",
"version": "1.1.6", "version": "1.1.7",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "astro dev", "dev": "astro dev",
@ -39,6 +39,7 @@
"lucide-react": "^0.441.0", "lucide-react": "^0.441.0",
"react": "^18.3.1", "react": "^18.3.1",
"react-dom": "^18.3.1", "react-dom": "^18.3.1",
"rehype-external-links": "^3.0.0",
"rehype-katex": "^7.0.0", "rehype-katex": "^7.0.0",
"rehype-pretty-code": "^0.14.0", "rehype-pretty-code": "^0.14.0",
"remark-emoji": "^5.0.1", "remark-emoji": "^5.0.1",

View file

@ -46,7 +46,7 @@ export async function getStaticPaths() {
<div class="flex flex-wrap items-center gap-2"> <div class="flex flex-wrap items-center gap-2">
<h1 class="text-3xl font-semibold">Posts tagged with</h1> <h1 class="text-3xl font-semibold">Posts tagged with</h1>
<span <span
class="flex items-center gap-x-1 rounded-full bg-secondary px-4 py-2 text-2xl font-bold" class="flex items-center gap-x-1 rounded-full bg-secondary px-4 py-2 text-2xl font-semibold"
> >
<Icon name="lucide:hash" class="size-6 -translate-x-0.5" />{tag} <Icon name="lucide:hash" class="size-6 -translate-x-0.5" />{tag}
</span> </span>

View file

@ -83,7 +83,7 @@
@layer components { @layer components {
article { article {
@apply prose-headings:scroll-mt-20 prose-headings:break-words prose-p:break-words prose-a:!break-words prose-a:!decoration-muted-foreground prose-a:underline-offset-[3px] prose-a:transition-colors hover:prose-a:!decoration-foreground prose-pre:!px-0 prose-img:mx-auto; @apply prose-headings:scroll-mt-20 prose-headings:break-words first:prose-headings:mt-0 prose-p:break-words prose-a:!break-words prose-a:!decoration-muted-foreground prose-a:underline-offset-[3px] prose-a:transition-colors hover:prose-a:!decoration-foreground prose-pre:!px-0 prose-img:mx-auto;
.katex-display { .katex-display {
@apply overflow-x-auto overflow-y-hidden py-4; @apply overflow-x-auto overflow-y-hidden py-4;