Easy link picker for inline links

When clicking the Link button in the markdown/html editor, allow to select records from certain models. A more user friendly link picker is easier for clients and will prevent broken links.


Here's how it could work:


1. Option flag per model: "show in link picker"

2. If flag is on for that model, then choose how the URL for that record is determined:

  • Use Record ID# 
  • Select a text field (e.g. slug, customID field). If model is a tree, tick yes/no to use this field recursively. 
  • Specify a path prefix and an extension suffix for the model 

3. When picking that record, the link is inserted as [text](url) based on above.

 

Example 1:

  • Model called Products 
  • Specified as Linkable, using Slug field, prefix: "products", suffix: ".html" 
  • Pick record "Apples" 
  • Link dropped is [text](/products/apples.html "Apples") 

Example 2:

  • Model called Services 
  • Specified as Linkable, using Record ID#, prefix: "", suffix: "" 
  • Pick record: "Web Design" 
  • Link dropped is [text](501234 "Web Design") 

Example 3:

  • Model called Categories, which is a tree 
  • Specified as Linkable, using field Short_Name recursively, prefix: "site/categories", suffix: "" 
  • Pick record: "Glam Rock" 
  • Link dropped is [text](/site/categories/rock/glam "Glam Rock") 


The benefit of dropping the Record ID rather than an actual URL is that the link becomes immune to breaking, as the Record ID will travel with the page even if you totally restructure the site. You simply have to parse the ID into the correct link in your SSG. The method I use for this is:

  • Create a data store of all pages in the site and their IDs 
  • Process content for links and find links which are just numbers (e.g. a liquid plugin can do this) 
  • Swap URL for URL of page for that ID in the data store

I recognise this is a somewhat complex feature request, but I think it's the simplest way possible of adding a link picker to replace typing URLs directly, and I really think that would go a long way towards improving the end client experience!

Thanks!

Login to post a comment