diff --git a/src/main/resources/lib/ssb/parts/highcharts/data/statBank.es6 b/src/main/resources/lib/ssb/parts/highcharts/data/statBank.es6 index f23fad89a..15bed7bd1 100644 --- a/src/main/resources/lib/ssb/parts/highcharts/data/statBank.es6 +++ b/src/main/resources/lib/ssb/parts/highcharts/data/statBank.es6 @@ -12,6 +12,7 @@ export function seriesAndCategoriesFromJsonStat(req, highchart, dataset, dataset if (filterOptions && filterOptions._selected && filterOptions._selected === 'municipalityFilter') { const municipality = getMunicipality(req) + if (!municipality) return undefined const filterTarget = filterOptions.municipalityFilter.municipalityDimension const filterTargetIndex = dataset && dataset.id.indexOf(filterTarget) dimensionFilter[filterTargetIndex] = parseDataWithMunicipality(dataset, filterTarget, municipality, xAxisLabel) diff --git a/src/main/resources/site/filters/router.ts b/src/main/resources/site/filters/router.ts index dc0672bd1..99a0306c5 100644 --- a/src/main/resources/site/filters/router.ts +++ b/src/main/resources/site/filters/router.ts @@ -22,7 +22,6 @@ exports.filter = function (req: XP.Request, next: (req: XP.Request) => XP.Respon const pageTitle = createPageTitle(req.path, municipality) if (paramKommune) { - log.info('Kommuneside via apache, kommune: ' + paramKommune + ' Request Url: ' + req.url) // @ts-ignore HMMMMMM this is probably really hacky req.params = { selfRequest: 'true', @@ -71,7 +70,6 @@ exports.filter = function (req: XP.Request, next: (req: XP.Request) => XP.Respon } } - log.info('Kommuneside via targetResponse, kommune: ' + region + ' Request Url: ' + req.url) return { body: targetResponse.body, } diff --git a/src/main/resources/site/pages/default/default.html b/src/main/resources/site/pages/default/default.html index a1d04ac01..645a18e01 100644 --- a/src/main/resources/site/pages/default/default.html +++ b/src/main/resources/site/pages/default/default.html @@ -43,7 +43,7 @@ - + @@ -65,7 +65,7 @@ -
+
diff --git a/src/main/resources/site/pages/default/default.ts b/src/main/resources/site/pages/default/default.ts index 12142913e..a003ff0c8 100644 --- a/src/main/resources/site/pages/default/default.ts +++ b/src/main/resources/site/pages/default/default.ts @@ -173,6 +173,11 @@ exports.get = function (req: XP.Request): XP.Response { } const pageType: string = pageConfig.pageType ? pageConfig.pageType : 'default' + const baseUrl: string = + app.config && app.config['ssb.baseUrl'] ? (app.config['ssb.baseUrl'] as string) : 'https://www.ssb.no' + let canonicalUrl: string | undefined = `${baseUrl}${pageUrl({ + path: page._path, + })}` let municipalPageType: string | undefined if (pageType === 'municipality') { if (page._path.includes('/kommunefakta/')) { @@ -189,10 +194,17 @@ exports.get = function (req: XP.Request): XP.Response { } } + if (pageType === 'municipality' && municipality) { + canonicalUrl = `${baseUrl}/${municipalPageType}${municipality.path}` + } + const metaInfo: MetaInfoData = parseMetaInfoData(municipality, pageType, page, language, req) const statbankFane: boolean = req.params.xpframe === 'statbank' const statBankContent: StatbankFrameData = parseStatbankFrameContent(statbankFane, req, page) + if (statbankFane) { + canonicalUrl = undefined + } const breadcrumbs: Breadcrumbs = getBreadcrumbs( page as unknown as Content, @@ -202,13 +214,10 @@ exports.get = function (req: XP.Request): XP.Response { const breadcrumbId = 'breadcrumbs' const hideBreadcrumb = !!pageConfig.hide_breadcrumb const innrapporteringRegexp = /^\/ssb(\/en)?\/innrapportering/ // Skal matche alle sider under /innrapportering på norsk og engelsk - const baseUrl: string = - app.config && app.config['ssb.baseUrl'] ? (app.config['ssb.baseUrl'] as string) : 'https://www.ssb.no' + const model: DefaultModel = { pageTitle: 'SSB', // not really used on normal pages because of SEO app (404 still uses this) - pageUrl: `${baseUrl}${pageUrl({ - id: page._id, - })}`, + canonicalUrl, page: page as unknown as Content, ...regions, ingress, @@ -600,7 +609,7 @@ export interface StatbankFrameData { interface DefaultModel { pageTitle: string - pageUrl: string | undefined + canonicalUrl: string | undefined page: Content ingress: string | undefined showIngress: string | boolean | undefined