From d0a310a5f4dd8331d3d6c2f729a62db3cceaf831 Mon Sep 17 00:00:00 2001 From: Glenruben Date: Fri, 26 Jan 2024 16:42:31 +0100 Subject: [PATCH] [MIM-1711] Add anchor field to content-type, show in view if it exists. (#2477) * Add anchor field to content-type * Anchor should apply to target url * Add regexp limitation and clarify tool tip --- .../site/content-types/menuBox/menuBox.xml | 24 ++++++++++++------- .../resources/site/parts/menuBox/menuBox.ts | 6 ++++- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/main/resources/site/content-types/menuBox/menuBox.xml b/src/main/resources/site/content-types/menuBox/menuBox.xml index b2d68a80a..2d61b7f4f 100644 --- a/src/main/resources/site/content-types/menuBox/menuBox.xml +++ b/src/main/resources/site/content-types/menuBox/menuBox.xml @@ -4,20 +4,20 @@ base:structured
- + - + - + - + ${site} @@ -27,7 +27,7 @@ true - + @@ -46,8 +46,16 @@ - - + + + + + + OBS: Kun bokstaver a-z, tall og bindestrek/underscore er tillatt! + + + [A-Za-z0-9_-] + diff --git a/src/main/resources/site/parts/menuBox/menuBox.ts b/src/main/resources/site/parts/menuBox/menuBox.ts index d622e4827..7361bc1ee 100644 --- a/src/main/resources/site/parts/menuBox/menuBox.ts +++ b/src/main/resources/site/parts/menuBox/menuBox.ts @@ -91,9 +91,12 @@ function getHref(menuConfig: MenuConfig): string { if (menuConfig.urlSrc && menuConfig.urlSrc._selected === 'manual') { return menuConfig.urlSrc.manual.url } else if (menuConfig.urlSrc && menuConfig.urlSrc.content) { - return pageUrl({ + const url = pageUrl({ id: menuConfig.urlSrc.content.contentId, }) + if (menuConfig.urlSrc.content.anchor) { + return url + '#' + menuConfig.urlSrc.content.anchor + } else return url } return '' } @@ -133,6 +136,7 @@ interface hrefContent { _selected: 'content' content: { contentId: string + anchor: string } }