Skip to content

Commit 336c8e2

Browse files
committed
Links page, open links in new tab, works
1 parent 43fb02f commit 336c8e2

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

docs/working-notes/todo3.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,16 +492,16 @@ ovo puca
492492
ovo radi
493493
'/src/assets/images/all-images/*.jpg',
494494
----
495-
remote markdown
496-
not generating id="..." links href="#..."
495+
remote markdown
496+
not generating id="..." links href="#..."
497497
custom my-prose-links
498498

499499
// dark theme for github markdown
500500
https://github.com/sindresorhus/github-markdown-css/issues/104
501501
https://github.com/sindresorhus/github-markdown-css
502502

503503
table of contents id links
504-
a href open in new tab
504+
a href open in new tab
505505
fix links page links color for history back view transition
506506

507507
refactor theme script, browserDefaultMode, appDefaultMode, storedMode
@@ -514,6 +514,11 @@ fix image sizes for gallery and other
514514
update bg color meta tag
515515
fix links page on user dark mode preference text color
516516

517-
Links page open links in new tab
517+
Links page open links in new tab
518+
// astro-remote, glavna fora je ovo
519+
<Markdown
520+
sanitize={{ allowComponents: true }} // enable custom components
521+
components={{ Heading, a: Anchor }} // a - koji tag predefinises // glavna fora
522+
/>
518523
------------
519524
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
const { href } = Astro.props;
3+
4+
// exists and external
5+
const isExternalLink = Boolean(href) && !href.startsWith('#');
6+
7+
const linkProps = {
8+
...(isExternalLink ? { target: '_blank' } : {}),
9+
};
10+
---
11+
12+
<a {href} {...linkProps}>
13+
<slot />
14+
</a>

src/components/remote-markdown/Heading.astro renamed to src/components/astro-remote/Heading.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const href = `#${slug}`;
1313
---
1414

1515
<div class="flex gap-2 items-center group">
16-
<a id={slug} href={href} class="flex target:!outline-none">
16+
<a id={slug} {href} class="flex target:!outline-none">
1717
<Icon
1818
name="mdi:link-variant"
1919
class="inline-block h-5 w-5 text-transparent group-hover:text-captions"

src/pages/links.astro

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import '@/assets/styles/github-markdown.css';
55
import { Markdown } from 'astro-remote';
66
77
import List from '@/layouts/List.astro';
8-
import Heading from '@/components/remote-markdown/Heading.astro';
8+
import Anchor from '@/components/astro-remote/Anchor.astro';
9+
import Heading from '@/components/astro-remote/Heading.astro';
910
import { BOOKMARKS } from '@/constants/data';
1011
import { SELECTORS } from '@/constants/dom';
1112
import { getPageMetadata } from '@/utils/metadata';
@@ -30,7 +31,7 @@ const { GITHUB_MARKDOWN_BODY_ID } = SELECTORS;
3031
<Markdown
3132
content={readmeContent}
3233
sanitize={{ dropElements: ['h1'], allowComponents: true }}
33-
components={{ Heading }}
34+
components={{ Heading, a: Anchor }}
3435
/>
3536
</div>
3637
</List>

0 commit comments

Comments
 (0)