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
2 changes: 2 additions & 0 deletions packages/astro-loader-obsidian/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"fast-glob": "^3.3.2",
"github-slugger": "^2.0.0",
"gray-matter": "^4.0.3",
"hast-util-from-html": "^2.0.3",
"hast-util-to-html": "^9.0.5",
"he": "^1.2.0",
"js-yaml": "^4.1.0",
"kleur": "^4.1.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ const { config, slug, class: className = "graph-full" } = Astro.props;
async loadData(): Promise<GraphViewData> {
const base = this.getAttribute("base");
const slug = this.getAttribute("slug");
const url = base ? `/${base.replace(/^\/+|\/+$/g, '')}/_spaceship/graph/${slug ?? "index"}.json` : `/_spaceship/graph/${slug ?? "index"}.json`;
const normalizedBase = base ? base.replace(/^\/+|\/+$/g, '') : '';
const url = normalizedBase ? `/${normalizedBase}/_spaceship/graph/${slug ?? "index"}.json` : `/_spaceship/graph/${slug ?? "index"}.json`;

const response = await fetch(url);
return response.json();
Expand Down
27 changes: 27 additions & 0 deletions packages/astro-spaceship/components/Layout/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,33 @@ const { language } = page;
<link rel="icon" type="image/svg+xml" href={`${config.base ?? '/'}favicon.svg`} />
<SEO page={page} />
<slot name="head" />
<style is:global>
.anchor-link {
text-decoration: none;
margin-left: 0.5rem;
opacity: 0;
transition: opacity 0.2s ease-in-out;
color: inherit;
display: inline-flex;
align-items: center;
vertical-align: middle;
}

h1:hover .anchor-link,
h2:hover .anchor-link,
h3:hover .anchor-link,
h4:hover .anchor-link,
h5:hover .anchor-link,
h6:hover .anchor-link {
opacity: 1;
}

.anchor-icon {
display: inline-block;
vertical-align: middle;
user-select: none;
}
</style>
</head>
<body class="body">
<div class="texture" />
Expand Down
2 changes: 2 additions & 0 deletions packages/astro-spaceship/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@
"memoize": "^10.1.0",
"playwright": "^1.54.2",
"reading-time": "^1.5.0",
"rehype-autolink-headings": "^7.1.0",
"rehype-callouts": "^2.1.2",
"rehype-mathjax": "^7.1.0",
"rehype-mermaid": "^3.0.0",
"rehype-rewrite": "^4.0.2",
"rehype-slug": "^6.0.0",
"remark-code-extra": "^1.0.1",
"remark-math": "^6.0.0",
"unist-util-visit": "^5.0.0",
Expand Down
56 changes: 56 additions & 0 deletions packages/astro-spaceship/shell/markdown/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import rehypeRewrite from "rehype-rewrite";
import remarkCodeExtra from "remark-code-extra";
import remarkMath from "remark-math";
import rehypeSlug from 'rehype-slug';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypeCallouts from 'rehype-callouts';
import rehypeMathjax from 'rehype-mathjax';
import rehypeMermaid from 'rehype-mermaid';
Expand Down Expand Up @@ -36,6 +38,60 @@ export default (
...remarkPlugins,
],
rehypePlugins: [
rehypeSlug,
[
rehypeAutolinkHeadings,
{
behavior: 'append',
properties: {
className: ['anchor-link'],
ariaLabel: 'Link to this section'
},
content: {
type: 'element',
tagName: 'svg',
properties: {
xmlns: 'http://www.w3.org/2000/svg',
width: '16',
height: '16',
viewBox: '0 0 24 24',
className: ['anchor-icon'],
ariaHidden: 'true'
},
children: [
{
type: 'element',
tagName: 'g',
properties: {
fill: 'none',
stroke: 'currentColor',
strokeLinecap: 'round',
strokeWidth: '1.5'
},
children: [
{
type: 'element',
tagName: 'path',
properties: {
d: 'M10.046 14c-1.506-1.512-1.37-4.1.303-5.779l4.848-4.866c1.673-1.68 4.25-1.816 5.757-.305s1.37 4.1-.303 5.78l-2.424 2.433'
},
children: []
},
{
type: 'element',
tagName: 'path',
properties: {
d: 'M13.954 10c1.506 1.512 1.37 4.1-.303 5.779l-2.424 2.433l-2.424 2.433c-1.673 1.68-4.25 1.816-5.757.305s-1.37-4.1.303-5.78l2.424-2.433',
opacity: '0.5'
},
children: []
}
]
}
]
}
}
],
[
rehypeCallouts,
{
Expand Down
Loading