feat: make the external link to be opened in new blank.

This commit is contained in:
Yufan Sheng 2024-06-25 20:21:22 +08:00
parent 84c3159bc2
commit 244e54c594
Signed by: syhily
GPG Key ID: 9D18A22A7DCD5A9B
5 changed files with 37 additions and 1 deletions

View File

@ -106,6 +106,7 @@
"recma",
"redmi",
"regclass",
"rehype",
"rivo",
"sauvignon",
"sheng",

View File

@ -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

View File

@ -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'],

33
package-lock.json generated
View File

@ -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",

View File

@ -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",