diff --git a/.vscode/settings.json b/.vscode/settings.json index e4558fc..b543a12 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -106,6 +106,7 @@ "recma", "redmi", "regclass", + "rehype", "rivo", "sauvignon", "sheng", diff --git a/README.md b/README.md index 820be68..f15740e 100644 --- a/README.md +++ b/README.md @@ -180,7 +180,6 @@ You should host it on your own machine. - [ ] Check article grammar errors by using ChatGPT. Remain **54** posts. - [ ] Add music to the articles. Remain **54** posts. -- [ ] External article inner links with different targets. - [ ] Slide share components integration. ### Comments TODO Checklist diff --git a/astro.config.ts b/astro.config.ts index 2857a63..fa6eb3a 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -1,6 +1,7 @@ import mdx from '@astrojs/mdx'; import node from '@astrojs/node'; import { defineConfig, envField } from 'astro/config'; +import rehypeExternalLinks from 'rehype-external-links'; import options from './options'; import { astroImage } from './plugins/images'; import { uploader } from './plugins/uploader'; @@ -35,6 +36,7 @@ export default defineConfig({ integrations: [ mdx({ remarkPlugins: [astroImage], + rehypePlugins: [[rehypeExternalLinks, { rel: 'nofollow', target: '_blank' }]], }), uploader({ paths: ['images', 'og', 'cats'], diff --git a/package-lock.json b/package-lock.json index 5b262c3..8809b7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,6 +40,7 @@ "prettier-plugin-astro": "^0.14.0", "prettier-plugin-astro-organize-imports": "^0.4.8", "prettier-plugin-organize-imports": "^3.2.4", + "rehype-external-links": "^3.0.0", "resize-sensor": "^0.0.6", "rimraf": "^5.0.7", "sharp": "^0.33.4", @@ -6274,6 +6275,19 @@ "integrity": "sha512-7NXolsK4CAS5+xvdj5OMMbI962hU/wvwoxk+LWR9Ek9bVtyuuYScDN6eS0rUm6TxApFpw7CX1o4uJzcd4AyD3Q==", "license": "MIT" }, + "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==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-alphabetical": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz", @@ -8839,6 +8853,25 @@ "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==", + "dev": true, + "license": "MIT", + "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-parse": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/rehype-parse/-/rehype-parse-9.0.0.tgz", diff --git a/package.json b/package.json index bffb35d..3300de7 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "prettier-plugin-astro": "^0.14.0", "prettier-plugin-astro-organize-imports": "^0.4.8", "prettier-plugin-organize-imports": "^3.2.4", + "rehype-external-links": "^3.0.0", "resize-sensor": "^0.0.6", "rimraf": "^5.0.7", "sharp": "^0.33.4",