question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Opt out of automatic nuxt-link for linking to static content

See original GitHub issue

Is your feature request related to a problem? Please describe.

All links that start with a ‘/’ are replaced with nuxt-link. This makes it impossible to link to some file in the static directory.

Describe the solution you’d like

There should be an option to opt out of autolinking, either as a new component, a tag, or a syntax modification to the link.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
btkostnercommented, Jun 14, 2021

In the mean time, here is a fix I’ve been using to undo the nuxt-link for static files:

import { extname } from 'path'

function maybeFixLink (node) {
  if (node.tag === 'nuxt-link') {
    const ext = extname(node.props.to)

    if (ext !== '') {
      node.tag = 'a'
      node.props.href = node.props.to
      node.props.rel = ['nofollow', 'noopener', 'noreferrer']
      node.props.target = '_blank'

      delete node.props.to
    }
  }

  if (node.children != null) {
    node.children.forEach(maybeFixLink)
  }
}

export default function (document) {
  if (document.extension !== '.md') {
    return
  }

  document.body.children.forEach(maybeFixLink)
}

then just put it on the content:file:beforeInsert like so:

import linkFixes from './link-fixes.js'

export default {
  hooks: {
    'content:file:beforeInsert': linkFixes
  }
}

Working example here: https://github.com/system76/docs/blob/master/modules/link-fixes.js

0reactions
schnetzicommented, Oct 4, 2022

I am having the same issue and I don’t understand why this was closed.

@btkostner thanks for your “temporary” fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue.js - Nuxt: How to create links in a loop using the data as ...
For each of the items I would like a link such as: For id a, the link should be /content/a; For id b,...
Read more >
Nuxt.js for Busy Developers - CODE Magazine
Nuxt.js generates a static version of your website. It takes all the routes you define in the app and stores them as separate...
Read more >
Building a static site with Nuxt, using Tailwind and Typescript
Exploring how easy it is to get started with a Vue.js-powered static site, using Tailwind and Typescript, and looking at the community-made ...
Read more >
Best Features in Nuxt 3
Link pre-fetching; Universal rendering; Hybrid rendering; Vite; First class TypeScript; Full static; File-based routing; Auto-imports; Simple and powerful ...
Read more >
Building a dynamic web app with Vuejs framework Nuxtjs + ...
Static content webpages: Create static pages easily. ... margin: auto; ... Sign In </a-button> </nuxt-link><nuxt-link to="/registration">
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found