Commit cb509b1
Changed files (4)
src
components
utils
content
posts
pages
posts
utils
src/components/utils/Markdown.astro
@@ -32,7 +32,7 @@ const {
const references = bidirectionalReferences?.references;
const allRefByCurrent = bidirectionalReferences?.allRefByCurrent;
const replacer = (_: string, reference: string, alias: string) => {
- const id = references?.find((item) => item.reference === reference)?.id;
+ const id = references?.find((item) => item.reference === reference.split('#')[0])?.id;
if (!id) return '';
const refTo = allRefByCurrent?.find((it) => it.id === id);
if (!refTo) return '';
src/content/posts/markdown.md
@@ -125,7 +125,7 @@ And that's it!
#### I Think You Want to Have a Look at Heading Level 4
-Bidirectional article links are also supported, you can use `[[slug]]` to create a link to another article like [[posts/create-custom-page/index|create custom page]] or [[manual]]
+Bidirectional article links are also supported, you can use `[[slug]]` to create a link to another article like [[posts/create-custom-page/index#Introduction|create custom page]] or [[manual]]
##### Too Many Nested Headings is Not a Good Idea, but Here is Heading Level 5
src/pages/posts/[article].astro
@@ -34,7 +34,18 @@ const references: {
reference: string;
context: string;
id: string;
-}[] = remarkPluginFrontmatter.references || [];
+}[] =
+ (
+ remarkPluginFrontmatter.references as {
+ reference: string;
+ context: string;
+ id: string;
+ }[]
+ )?.map((it) => ({
+ reference: it.reference.split('#')[0],
+ context: it.context,
+ id: it.id,
+ })) || [];
const backLinks: {
refBy: {
src/utils/content-utils.ts
@@ -146,7 +146,12 @@ export async function getAllReferences() {
title: post.data.title,
colletion: 'posts',
id: post.id,
- references,
+ references: references.map((ref) => ({
+ reference: ref.reference.split('#')[0],
+ context: ref.context,
+ offset: ref.offset,
+ id: ref.id,
+ })),
};
});
const specRefData = specs.map(async (spec) => {