npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

apostrophe-rich-text-permalinks

v2.0.5

Published

Enhances ApostropheCMS rich text widgets with smart links, rich inline tooltips, and in-text variable replacement

Downloads

64

Readme

With this module, your users can create a link to a page in ApostropheCMS...

By picking "Pages" from the "Link Types" menu in CKEditor...

... Then choosing a page in Apostrophe's page tree.

Users can click the usual "link" icon in the rich text editor, then pick "Document" from the "Link Types" dropdown menu.

Now they can click the "Browse Documents" button and select the page they wish to link to.

The resulting link will always stay up to date, even if the page moves around the site and its slug changes. This is the main advantage, in addition to the simple convenience of picking a page via the page tree.

Installation

npm install apostrophe-rich-text-permalinks
// in app.js
modules: {
  'apostrophe-rich-text-permalinks': {}
}

Linking to other document types

You can open this up to linking to other types via the join option:

// in app.js
modules: {
  'apostrophe-rich-text-permalinks': {
    join: {
      withType: 'apostrophe-blog-post'
    }
  }
}

You can even specify more than one type. Use the special type apostrophe-page to refer to all pages:

// in app.js
modules: {
  'apostrophe-rich-text-permalinks': {
    join: {
      // Either a page or a blog post
      withType: [ 'apostrophe-page', 'apostrophe-blog-post' ]
    }
  }
}

You may successfully create permalinks to any type of document that has a _url property when loaded, i.e. pieces that have corresponding pieces-pages, as well as regular pages.

Projections

By default, a conservative projection is used for joined documents (only title and _url by default). You can pass your own projection like so:

// in app.js
modules: {
  'apostrophe-rich-text-widgets': {
    projection: {
      title: 1,
      _url: 1,
      attachment: 1
    }
  }
}

This is particularly useful if you're including something like apostrophe-file as a join option.

Changing the label and buttons

By default, the new item on the "Link Type" dropdown and the "Browse" button both get labels based on the type of document you are joining with. But if you want to change this language, or you are using an array of types and find the word "Documents" underwhelming, you can set the browseLabel and typeLabel options of this module as you see fit.

Things to be aware of

While users are logged in with editing privileges, the link will look like this:

#apostrophe-permalink-ID-OF-PAGE?updateTitle=1

However, for their convenience, if they click on it while the rich text editor is not active, it will still redirect to the right place.

The link will always point directly to its destination for all other site visitors, including search engines, which means the SEO is good.

On each page load that actually features permalinks, there is a small performance hit to load information about the current location of all the pages being linked to. However Apostrophe makes an effort to load these collectively rather than one at a time. There is no significant performance hit on pages that don't have permalinks.