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

@gitlab/nuxt-edit-this-page

v1.0.0

Published

Add an 'Edit this page' link to your Nuxt pages

Downloads

990

Readme

nuxt-edit-this-page

pipeline status npm (scoped with tag) npm

Add an "Edit this page" link to your Nuxt pages

📖 Release Notes

Features

This module let's you add "Edit this page" links to your Nuxt project's pages. The link opens the web IDE for the active file, which is the page's Vue file by default but that can be changed as needed by using a custom path resolver.

Supported Git services

Setup

  • Install the module with your favorite package manager.
yarn add @gitlab/nuxt-edit-this-page
# Or npm i @gitlab/nuxt-edit-this-page
  • Add @gitlab/nuxt-edit-this-page to the modules section in nuxt.config.js.
// nuxt.config.js
{
  modules: [
    '@gitlab/nuxt-edit-this-page',
 ],
}
  • Configure the module as needed by adding an editThisPage key to nuxt.config.js.
// nuxt.config.js
{
  editThisPage: {
    // Module options
  }
}

Usage

When enabled, the module registers a global component that you can use to display an "Edit this page" link in any of your page. The component will automatically generate a link based on the route that's being visited so that you can quickly access the live editor on the Git hosting service.

<template>
  <edit-this-page-link />
</template>

The component accepts a few props to customize the ads you display.

Options

repo

  • Type: String: required

The remote Git repository where the files reside, can be an HTTPS URL or an SSH address.

Example:

// nuxt.config.js
{
  editThisPage: {
    repo: '[email protected]:gitlab-org/frontend/nuxt-edit-this-page.git',

    // Or
    // repo: 'https://gitlab.com/gitlab-org/frontend/nuxt-edit-this-page.git',

    // Also works with the project's URL
    // repo: 'https://gitlab.com/gitlab-org/frontend/nuxt-edit-this-page',
  }
}

path

  • Type: String
  • Default: 'blob'

The path option is appended to the base edit URL. By default, the blob path is used, which produces URLs like https://gitlab.com/gitlab-org/frontend/nuxt-edit-this-page/blob/master/README.md. This option could be used to make the URL point to the edit path directly, ie setting path to 'edit' would produce URLs like https://gitlab.com/gitlab-org/frontend/nuxt-edit-this-page/edit/master/README.md.

branch

  • Type: String
  • Default: 'master'

Git branch to use when editing files.

linkText

  • Type: String
  • Default: 'Edit this page'

Text to show when rendering the link.

componentName

  • Type: String
  • Default: 'EditThisPageLink'

The component's name.

Props

The component accepts a few props that let you override the module's options if needed.

editUrl

  • Type: String

Base URL to prepend to the file path when generating the edit link. This is computed automatically based on the repo and branch options, use it when you need to override the URL on a case-per-case basis.

linkText

  • Type: String

Text to show when rendering the link. Defaults to the value set in the module's options.

Scoped slot

The component exposes a scoped slot that you can use to customize the rendering if props are too limited. The slot receives a property href that contains the computed edit URL.

Example

<template>
  <edit-this-page-link>
    <template v-slot:default="{ href }">
      <span>Customized link pointing to {{ href }}</span>
    </template>
  </edit-this-page-link>
</template>

Custom path resolver

Sometimes, your pages display contents from other files and you might want the "Edit this page" link to point to the included file, rather than the visited page's component. This can be achieved by adding an editThisPage.resolve option to your page. editThisPage.resolve is a function that receives the current route and should return the computed file path relative to the repository's root.

Example:

<template>
  <!-- pages/_slug.vue -->
</template>

<script>
export default {
  editThisPage: {
    resolve({ route }) {
      const { slug } = route.params;
      return `docs/${slug}.md`;
    },
  },
};
</script>

Development

  • Clone this repository
  • Install dependencies using yarn install
  • Start development server using yarn dev

License

MIT License

Copyright (c) GitLab