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

Add preview and edit mode for fragments #2048

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions src/main/resources/site/pages/default/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ <h2 data-th-if="${region.view == 'card' && !region.hideTitle && region.title}" c
</div>
</main>

<main class="xp-region" id="content" data-th-if="${isFragment}">
<div data-portal-component="fragment" data-th-remove="tag"></div>
</main>

<!-- FOOTER -->
<footer data-th-if="${footerBody}" id="footer" data-th-utext="${footerBody}" data-th-remove="tag">
</footer>
Expand Down
8 changes: 5 additions & 3 deletions src/main/resources/site/pages/default/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ exports.get = function (req: XP.Request): XP.Response {
const page = getContent<Content<Page> & DefaultPage>()
if (!page) return { status: 404 }

const pageConfig: DefaultPageConfig = page.page.config
const pageConfig: DefaultPageConfig = page.page?.config

const ingress: string | undefined = page.data.ingress
? processHtml({
Expand Down Expand Up @@ -172,7 +172,7 @@ exports.get = function (req: XP.Request): XP.Response {
municipality = getMunicipality(req)
}

const pageType: string = pageConfig.pageType ? pageConfig.pageType : 'default'
const pageType: string = 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({
Expand Down Expand Up @@ -212,10 +212,11 @@ exports.get = function (req: XP.Request): XP.Response {
statbankFane ? statBankContent : undefined
)
const breadcrumbId = 'breadcrumbs'
const hideBreadcrumb = !!pageConfig.hide_breadcrumb
const hideBreadcrumb = !!pageConfig?.hide_breadcrumb
const innrapporteringRegexp = /^\/ssb(\/en)?\/innrapportering/ // Skal matche alle sider under /innrapportering på norsk og engelsk

const model: DefaultModel = {
isFragment,
pageTitle: 'SSB', // not really used on normal pages because of SEO app (404 still uses this)
canonicalUrl,
page: page as unknown as Content,
Expand Down Expand Up @@ -609,6 +610,7 @@ export interface StatbankFrameData {
}

interface DefaultModel {
isFragment: boolean
pageTitle: string
canonicalUrl: string | undefined
page: Content
Expand Down