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
5 changes: 5 additions & 0 deletions lib/api-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ export function padNumber(num: number, size = 10) {
return s;
}

// replaces relative /content links with /api/content links
export function replaceContentLinks(content: string) {
return content.replace(/="\/content\//g, '="/api/content/');
}

/////////////////////////
// GETTERS
/////////////////////////
Expand Down
3 changes: 2 additions & 1 deletion src/routes/view-news.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '@chakra-ui/react';
import { useEffect, useMemo, useState } from 'react';
import { Link, useLocation } from 'react-router-dom';
import { replaceContentLinks } from '../../lib/api-helpers';
import { InscriptionMeta, OrdinalNews } from '../../lib/api-types';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
Expand Down Expand Up @@ -244,7 +245,7 @@ export default function ViewNews() {
/>
<ReactMarkdown
components={ChakraUIRenderer()}
children={news.body}
children={replaceContentLinks(news.body)}
remarkPlugins={[remarkGfm]}
rehypePlugins={[rehypeRaw]}
className="ord-news"
Expand Down