File tree Expand file tree Collapse file tree 3 files changed +36
-21
lines changed
pages/[library]/magazines Expand file tree Collapse file tree 3 files changed +36
-21
lines changed Original file line number Diff line number Diff line change @@ -113,22 +113,25 @@ const HeaderLinks: React.FC<{ library: LibraryData }> = ({ library }) => {
113113 { libraryWebsite . title ?? `${ libraryName } Home` }
114114 </ AnchorButton >
115115 ) }
116- < NavButton
117- variant = "ghost"
118- color = "ui.black"
119- href = "/magazines"
120- sx = { { mr : 1 } }
121- >
122- Magazines (logged in users)
123- </ NavButton >
124- < NavButton
125- variant = "ghost"
126- color = "ui.black"
127- href = "/magazines-preview"
128- sx = { { mr : 1 } }
129- >
130- Magazines (anonymous users)
131- </ NavButton >
116+ { isAuthenticated ? (
117+ < NavButton
118+ variant = "ghost"
119+ color = "ui.black"
120+ href = "/magazines"
121+ sx = { { mr : 1 } }
122+ >
123+ Magazines
124+ </ NavButton >
125+ ) : (
126+ < NavButton
127+ variant = "ghost"
128+ color = "ui.black"
129+ href = "/magazines-preview"
130+ sx = { { mr : 1 } }
131+ >
132+ Magazines
133+ </ NavButton >
134+ ) }
132135 < NavButton
133136 variant = "ghost"
134137 color = "ui.black"
Original file line number Diff line number Diff line change @@ -44,8 +44,21 @@ export function getMagazineApiUrl(): string {
4444 * Get the allowed origin for magazine iframe communication
4545 */
4646export function getMagazineAllowedOrigin ( ) : string {
47- const baseUrl = getMagazineReaderUrl ( ) ;
48- return process . env . NEXT_PUBLIC_MAGAZINES_ORIGIN || new URL ( baseUrl ) . origin ;
47+ const overrideOrigin = process . env . NEXT_PUBLIC_MAGAZINES_ORIGIN ;
48+
49+ if ( overrideOrigin ) {
50+ try {
51+ return new URL ( overrideOrigin ) . origin ;
52+ } catch {
53+ // Ignore invalid override and fall back to reader base URL origin.
54+ }
55+ }
56+
57+ try {
58+ return new URL ( getMagazineReaderUrl ( ) ) . origin ;
59+ } catch {
60+ return MAGAZINE_READER_URLS . production ;
61+ }
4962}
5063
5164/**
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import * as React from "react";
77import { NextPage , GetStaticProps , GetStaticPaths } from "next" ;
88import LayoutPage from "components/LayoutPage" ;
99import withAppProps , { AppProps } from "dataflow/withAppProps" ;
10- // import useUser from "components/context/UserContext";
10+ import useUser from "components/context/UserContext" ;
1111import useLogin from "auth/useLogin" ;
1212import useLibraryContext from "components/context/LibraryContext" ;
1313import {
@@ -20,8 +20,7 @@ import BreadcrumbBar from "components/BreadcrumbBar";
2020
2121const MagazinesFixedContent : React . FC = ( ) => {
2222 const iframeRef = React . useRef < HTMLIFrameElement | null > ( null ) ;
23- const token = "MOCK_TOKEN" ;
24- // const { token } = useUser();
23+ const { token } = useUser ( ) ;
2524 const { initLogin } = useLogin ( ) ;
2625 const { slug } = useLibraryContext ( ) ;
2726
You can’t perform that action at this time.
0 commit comments