Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include page mention excerpt from markdown files in ‘Referred in’ #18

Open
keikhcheung opened this issue Jun 19, 2020 · 4 comments
Open
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@keikhcheung
Copy link

Would it be possible to include excerpts from markdown files in the ‘Referred in’ section?

Currently, if the mention comes from notes originating from Roam, the parent block with the page mention is shown as a bullet point unter the page title.
But for local markdown files, only the page title is given.

Screenshot 2020-06-19 at 17 50 49

If it is possible to extract and display the sentence or the paragraph where the parent page mention is, or even showing the first paragraph of this parent note as a preview, it would be make ‘Referred in’ more content-rich for markdown files, and also appear to be more consistent with Roam notes.

@mathieudutour
Copy link
Owner

Ah yeah I'm sure that's possible

@mathieudutour mathieudutour added enhancement New feature or request good first issue Good for newcomers labels Jun 19, 2020
@Am3ra
Copy link

Am3ra commented Sep 30, 2020

@mathieudutour I would like to solve this, could you give me some pointers?

@mathieudutour
Copy link
Owner

mathieudutour commented Sep 30, 2020

So the goal is to add some content here: https://github.com/mathieudutour/gatsby-digital-garden/blob/master/packages/gatsby-theme-garden/src/utils/data-to-note.js#L51

To do so, we need to change the graphql query that get those. Because we support 3 difference types of sources (roam + local files, roam only, files only), there is a bit of a hack to make sure gatsby doesn't crash. So there is 3 different queries, we only need to change 2 of them:

Here we need to change inboundReferences to get the content we want in.

The main thing is to know what is the content we want.

If it's the excerpt of the content (the first few lines), it's pretty easy to get it (there is a field in the graphql schema for it).
If it's the content around the reference, then it's a lot harder because we would need to get the entire content, somehow find the reference and then display it while removing all the markdown stuff.

I didn't get around fixing this issue because I wanted the 2nd one - but maybe we can start with the first one and think about the second later.

Let me know if that makes no sense

@keikhcheung
Copy link
Author

@mathieudutour If we could extract from the beginning of the paragraph where the page is referenced, that would be really great.

Nonetheless, I am also trying to just get just the general excerpt of the source reference note from the graphql. But I cannot figure out why it is always returning undefined. I tried following your hints and what I did is:

  1. Adding excerpt after L37 in https://github.com/mathieudutour/gatsby-digital-garden/blob/master/packages/gatsby-theme-garden/fragments/file-and-roam.fragment#L37
  2. Similarly, adding excerpt after L21 in https://github.com/mathieudutour/gatsby-digital-garden/blob/master/packages/gatsby-theme-garden/fragments/file.fragment#L21
  3. Adding {node.excerpt} after L12 in https://github.com/mathieudutour/gatsby-digital-garden/blob/master/packages/gatsby-theme-garden/src/components/reference.js#L12
  4. Adding excerpt: ref.excerpt, after L53 in https://github.com/mathieudutour/gatsby-digital-garden/blob/master/packages/gatsby-theme-garden/src/utils/data-to-note.js#L53

And excerpt is undefined in the console.

Not very talented with Gatsby, I would appreciate any other tips that could shine some light. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants