diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2025-04-29 08:56:04 +0200 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-04-29 08:57:05 +0200 |
| commit | 8fecbcbba2eef19f4adf3c95573f8330746335b7 (patch) | |
| tree | e5f20895c0bbe1ba85026f2be15894eb622ec49a | |
| parent | 8cb952f30798d545f5d0f0690ab02df7eb978a74 (diff) | |
Indicate external links
| -rw-r--r-- | .husky/pre-commit | 1 | ||||
| -rw-r--r-- | astro.config.mjs | 14 | ||||
| -rw-r--r-- | package-lock.json | 31 | ||||
| -rw-r--r-- | package.json | 1 | ||||
| -rw-r--r-- | src/layouts/Layout.astro | 13 | ||||
| -rw-r--r-- | src/partials/Footer.astro | 3 |
6 files changed, 59 insertions, 4 deletions
diff --git a/.husky/pre-commit b/.husky/pre-commit index a5bb86d..0ad376d 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,2 +1 @@ -npm run format:dry npm run check diff --git a/astro.config.mjs b/astro.config.mjs index 19df8a3..b4fe6c6 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -4,6 +4,7 @@ import { defineConfig } from "astro/config"; import mdx from "@astrojs/mdx"; import icon from "astro-icon"; +import rehypeExternalLinks from "rehype-external-links"; export default defineConfig({ compressHTML: true, @@ -21,4 +22,17 @@ export default defineConfig({ inlineStylesheets: "never", }, scopedStyleStrategy: "where", + markdown: { + rehypePlugins: [ + [ + rehypeExternalLinks, + { + "rel": ["nofollow", "noopener"], + "properties": { + "className": "external", + } + } + ] + ] + } }); diff --git a/package-lock.json b/package-lock.json index 467d816..57586b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "bootstrap-icons": "^1.11.3", "braces": "3.0.3", "husky": "^9.1.7", + "rehype-external-links": "^3.0.0", "typescript": "5.8.2" }, "devDependencies": { @@ -4422,6 +4423,18 @@ "url": "https://github.com/sponsors/brc-dd" } }, + "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==", + "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", @@ -6473,6 +6486,24 @@ "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==", + "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.1", "resolved": "https://registry.npmjs.org/rehype-parse/-/rehype-parse-9.0.1.tgz", diff --git a/package.json b/package.json index 2b4a113..166ff7f 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "bootstrap-icons": "^1.11.3", "braces": "3.0.3", "husky": "^9.1.7", + "rehype-external-links": "^3.0.0", "typescript": "5.8.2" }, "devDependencies": { diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index f1c37c9..976e8a3 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -32,7 +32,10 @@ const { title, description, empty } = Astro.props; <meta property="og:title" content={title} /> <meta property="og:description" content={description} /> <meta property="og:type" content="website" /> - <meta property="og:url" content={Astro.url.toString().replace(".html", "")} /> + <meta + property="og:url" + content={Astro.url.toString().replace(".html", "")} + /> <meta property="og:image" content="/favicon.png" /> <meta name="twitter:card" content="summary" /> @@ -86,6 +89,14 @@ const { title, description, empty } = Astro.props; color: $accent; } + a.external::after { + content: "↗"; + font-family: monospace; + font-size: 0.85em; + display: inline-block; + transform: translateY(-1px); + } + *::selection { background-color: color.adjust($accent, $alpha: -0.85); } diff --git a/src/partials/Footer.astro b/src/partials/Footer.astro index f90c820..bc30217 100644 --- a/src/partials/Footer.astro +++ b/src/partials/Footer.astro @@ -11,8 +11,7 @@ import t from "../i18n/es.json"; <p> {t.footer.contentLicencedUnder} - <a - href={`https://creativecommons.org/licenses/by-sa/4.0/deed.es`} + <a href={`https://creativecommons.org/licenses/by-sa/4.0/deed.es`} >CC BY-SA 4.0</a >. |
