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

Fix citation button on Explore page #170

Merged
merged 6 commits into from
Oct 4, 2024
Merged

Conversation

Not-Abram
Copy link
Collaborator

No description provided.

Copy link

cloudflare-workers-and-pages bot commented Sep 24, 2024

Deploying topology with  Cloudflare Pages  Cloudflare Pages

Latest commit: 684f850
Status: ✅  Deploy successful!
Preview URL: https://d4b1fd64.topology.pages.dev
Branch Preview URL: https://not-abram-citation-button-5pdg.topology.pages.dev

View logs

@StevenClontz
Copy link
Member

The {#key markdown} suggestion I made earlier fails because markdown isn't being updated after the mount.

I think surrounding the whole component with {#key title} will trigger a remount and get us the result we want.

@StevenClontz
Copy link
Member

Some hints to get this working.

First, we can replace the use of window (which only exists once the component is mounted) by instead using

https://learn.svelte.dev/tutorial/page-store

by adding this line

import { page } from '$app/stores'

this gives us access to the current URL throughout the component as $page.url (note the necessary $), which we should use instead of setting a url variable.

Finally, we won't set markdown during onMount. Instead, we'll make it reactive by using the dollar sign feature of Svelte:

$: markdown = `[${title}](${$page.url})`

Then the {#key title} block turns out to be unnecessary.


Spoiler (use ROT13.com:

<fpevcg ynat="gf">
  vzcbeg { cntr } sebz '$ncc/fgberf'
  vzcbeg PbclOhggba sebz './PbclOhggba.firygr'
  rkcbeg yrg gvgyr: fgevat =
    'π-Onfr, n pbzzhavgl qngnonfr bs gbcbybtvpny pbhagrerknzcyrf.'
  $: znexqbja = `[${gvgyr}](${$cntr.hey})`
</fpevcg>

👆 this, plus some changes to the body of the component, seems to work for me.

Copy link
Member

@StevenClontz StevenClontz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments above (marking as "request changes" so this doesn't get merged accidentally)

@StevenClontz StevenClontz changed the title Added key to markdown Fix citation button on Explore page Sep 25, 2024
@StevenClontz StevenClontz merged commit 6958439 into main Oct 4, 2024
3 checks passed
@StevenClontz StevenClontz deleted the not-abram/citation-button branch October 4, 2024 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants