From 63075c650bf990407e9eefe3e9f135b2425a2ded Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 23 Oct 2023 13:48:47 -0300 Subject: content, css: linkTemplate: new linkless slot --- src/content/dependencies/linkTemplate.js | 35 ++++++++++++++++++-------------- src/content/dependencies/linkThing.js | 2 ++ src/static/site5.css | 8 ++++++++ 3 files changed, 30 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/content/dependencies/linkTemplate.js b/src/content/dependencies/linkTemplate.js index 7206e960..d9af726c 100644 --- a/src/content/dependencies/linkTemplate.js +++ b/src/content/dependencies/linkTemplate.js @@ -15,6 +15,7 @@ export default { href: {type: 'string'}, path: {validate: v => v.validateArrayItems(v.isString)}, hash: {type: 'string'}, + linkless: {type: 'boolean', default: false}, tooltip: {type: 'string'}, attributes: {validate: v => v.isAttributes}, @@ -33,25 +34,29 @@ export default { let style; let title; - if (slots.href) { - href = encodeURI(slots.href); - } else if (!empty(slots.path)) { - href = to(...slots.path); + if (slots.linkless) { + href = null; } else { - href = ''; - } + if (slots.href) { + href = encodeURI(slots.href); + } else if (!empty(slots.path)) { + href = to(...slots.path); + } else { + href = ''; + } - if (appendIndexHTML) { - if ( - /^(?!https?:\/\/).+\/$/.test(href) && - href.endsWith('/') - ) { - href += 'index.html'; + if (appendIndexHTML) { + if ( + /^(?!https?:\/\/).+\/$/.test(href) && + href.endsWith('/') + ) { + href += 'index.html'; + } } - } - if (slots.hash) { - href += (slots.hash.startsWith('#') ? '' : '#') + slots.hash; + if (slots.hash) { + href += (slots.hash.startsWith('#') ? '' : '#') + slots.hash; + } } if (slots.color) { diff --git a/src/content/dependencies/linkThing.js b/src/content/dependencies/linkThing.js index e661ca7c..b20b132b 100644 --- a/src/content/dependencies/linkThing.js +++ b/src/content/dependencies/linkThing.js @@ -36,6 +36,7 @@ export default { }, anchor: {type: 'boolean', default: false}, + linkless: {type: 'boolean', default: false}, attributes: {validate: v => v.isAttributes}, hash: {type: 'string'}, @@ -78,6 +79,7 @@ export default { attributes: slots.attributes, hash: slots.hash, + linkless: slots.linkless, }); }, } diff --git a/src/static/site5.css b/src/static/site5.css index 6076228b..d50d4623 100644 --- a/src/static/site5.css +++ b/src/static/site5.css @@ -439,6 +439,14 @@ a.current { font-weight: 800; } +a:not([href]) { + cursor: default; +} + +a:not([href]):hover { + text-decoration: none; +} + .nav-main-links > span > span { white-space: nowrap; } -- cgit 1.3.0-6-gf8a5