Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mimir 1776 canonical url kommunesider #1949

Merged
merged 5 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/site/filters/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
req.params = {
selfRequest: 'true',
municipality: JSON.stringify(municipality),
Expand Down Expand Up @@ -68,7 +67,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,
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/site/pages/default/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<link rel="preload" data-th-href="${stylesUrl}" as="style" />
<link rel="stylesheet" data-th-href="${stylesUrl}"/>
<link rel="alternate" data-th-if="${alternateLanguageVersionUrl}" data-th-href="${alternateLanguageVersionUrl}" data-th-hreflang="${language.alternate}"/>
<link data-th-unless="${statbankWeb}" rel="canonical" data-th-href="${pageUrl}" />
<link data-th-if="${canonicalUrl}" rel="canonical" data-th-href="${canonicalUrl}" />

</head>
<body class="xp-page" data-th-classappend="${bodyClasses}">
Expand All @@ -65,7 +65,7 @@
</div>

<!-- Metainfo to make the page searchable -->
<div id="metainfo-container" data-th-if="${addMetaInfoSearch}" data-th-include="mimir:/site/includes/metainfoSearch.html" data-th-remove="tag"></div>
<div id="metainfo-container" data-th-if="${addMetaInfoSearch}" data-th-insert="~{mimir:/site/includes/metainfoSearch.html}" data-th-remove="tag"></div>

<!-- MAIN -->
<main class="xp-region" id="content" data-th-if="${!isFragment}">
Expand Down
21 changes: 15 additions & 6 deletions src/main/resources/site/pages/default/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,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({
id: page._id,
ssb-cgn marked this conversation as resolved.
Show resolved Hide resolved
})}`
let municipalPageType: string | undefined
if (pageType === 'municipality') {
if (page._path.includes('/kommunefakta/')) {
Expand All @@ -188,22 +193,26 @@ 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, municipality, statbankFane ? statBankContent : undefined)
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,
...regions,
ingress,
Expand Down Expand Up @@ -596,7 +605,7 @@ export interface StatbankFrameData {

interface DefaultModel {
pageTitle: string
pageUrl: string | undefined
canonicalUrl: string | undefined
page: Content
ingress: string | undefined
showIngress: string | boolean | undefined
Expand Down