Skip to content
Open
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: 3 additions & 1 deletion src/app/components/book-tile/book-tile-display.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {Item} from '~/models/book-titles';
import {Book as BookInfo} from '~/pages/subjects/new/specific/context';
import GetTheBookDropdown from './dropdown-menu';
import cn from 'classnames';
import usePortalContext from '~/contexts/portal';
import './book-tile.scss';

type AdditionalFields = Partial<{
Expand All @@ -16,6 +17,7 @@ export default function BookTile({book}: {book: BookInfo & AdditionalFields}) {
const comingSoon = book.bookState === 'coming_soon';
const snippets = book.promoteSnippet?.filter((s) => s.value.image);
const promoteSnippet = snippets?.find((s) => s.value.image);
const {portalPrefix} = usePortalContext();
const classes = cn({
'book-tile': true,
'coming-soon': comingSoon,
Expand All @@ -24,7 +26,7 @@ export default function BookTile({book}: {book: BookInfo & AdditionalFields}) {

return (
<div className={classes}>
<a href={`/details/${slug}`} aria-label={`${title} book`}>
<a href={`${portalPrefix}/details/${slug}`} aria-label={`${title} book`}>
<img
src={coverUrl}
role='presentation'
Expand Down
2 changes: 1 addition & 1 deletion src/app/helpers/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {WindowWithSettings} from './window-settings';

const EXTERNAL = /^([a-z]+:)/;
const ABSOLUTE_OPENSTAX = new RegExp(
`(?:https?://openstax.org|${window.location.origin})(?!/(?:books|accounts|oxauth|blog-feed|documents)/)`
`(?:https?://openstax.org|${window.location.origin})(?!/(?:(?:.*/)?books|accounts|oxauth|blog-feed|documents)/)`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rex books links may have a portal prefix

);
const MAILTO = /^mailto:(.+)/;

Expand Down
2 changes: 1 addition & 1 deletion src/app/helpers/rex-portal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export function useRexPortalLinkOrNot(link: string) {
if (!portalPrefix) {
return link;
}
return link.replace('books/', `portal${portalPrefix}/books/`);
return link.replace('books/', `apps/rex/portal${portalPrefix}/books/`);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default function ContentWarning({
{...(track ? {'data-track': track} : {})}
onClick={closeAfterDelay}
className="btn go-to"
data-local="true"
>
Go to your {variant === 'View online' ? 'book' : 'file'}
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default function GiveBeforeOther({
className='btn go-to'
{...(track ? {'data-track': track} : {})}
data-variant={lookupVariant(variant)}
data-local="true"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes the Rex link to open in the current tab even though it's an "external" link.

>
Go to your {lookupVariant(variant)}
</a>
Expand Down