@gitlab/nuxt-edit-this-page

中文文档
1.0.0发布于 2019/06/25MITCommonJS零依赖近 30 天下载 3024

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

原始使用文档
文档目录16 节
  1. Features
  2. Supported Git services
  3. Setup
  4. Usage
  5. Options
  6. repo
  7. path
  8. branch
  9. linkText
  10. componentName
  11. Props
  12. linkText
  13. Scoped slot
  14. Custom path resolver
  15. Development
  16. License

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

版本与发布记录

@gitlab/nuxt-edit-this-page 共发布 2 个版本,首次发布于 2019/06/20;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.0latest2019/06/257 年前
0.1.02019/06/207 年前

关于 @gitlab/nuxt-edit-this-page 的常见问题

@gitlab/nuxt-edit-this-page 是什么?

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

如何安装 @gitlab/nuxt-edit-this-page?

在项目目录运行 npm install @gitlab/nuxt-edit-this-page,或使用 pnpm add / yarn add / bun add。

@gitlab/nuxt-edit-this-page 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/gitlab__nuxt-edit-this-page 是否存在。

@gitlab/nuxt-edit-this-page 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@gitlab/nuxt-edit-this-page 可以商用吗?

@gitlab/nuxt-edit-this-page 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@gitlab/nuxt-edit-this-page 的下载量有多少?

根据 npm 官方下载统计,@gitlab/nuxt-edit-this-page 在 2026/10/17 – 2026/11/15 这 30 天内被下载 3,024 次,日均约 101 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gitlab/nuxt-edit-this-page 还在维护吗?

最新版本 1.0.0 发布于 2019/06/25(7 年前);至今共发布 2 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/06/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。