vuepress-plugin-autometa icon indicating copy to clipboard operation
vuepress-plugin-autometa copied to clipboard

Permalink is not reflected

Open tmiame opened this issue 6 years ago • 4 comments

Description

Autometa has not catch the rewritten by another extended function.

This problem may be a problem to be solved by the Vuepress core in the future, such as setting the execution order of plugins.

What do you think about this problem?

Temporary solution

before

module.exports = ( plugin_options, context ) => ({
  extendPageData ( $page ) {
    const { frontmatter } = $page;
    ...

after

module.exports = ( plugin_options, context ) => ({
  ready () {
    const { pages } = context
  
    pages.forEach( page => {
      const { frontmatter } = page;
      ...

Expected Behavior

/about.md

---
title: Hello
permalink: about-page
---

# About

output

/about-page/index.html

<!DOCTYPE html>
<head>
  <meta name="twitter:url" content="https://example.com/about-page/">
  ...

Actual Behavior

/about.md

---
title: Hello
permalink: about-page
---

# About

output

/about-page/index.html

<!DOCTYPE html>
<head>
  <meta name="twitter:url" content="https://example.com/about.html">
  ...

Your Environment

  • vuepress-plugin-autometa version: 0.1.10
  • vuepress version: 1.0.0-alpha.40
  • node version: 10.7.0
  • npm version: 6.6.0
  • OS: MacOS 10.14.2

sorry, I'm using translation. love this plugin. thanks!

tmiame avatar Feb 27 '19 08:02 tmiame

Thank you @tmiame for the feedback!

Here's what I think:

  • is the other extended function done with another plugin, and if so, have you tried adding autometa plugin after it?
  • using your temporary solution of using the ready hook function would not be enough to get all $page properties, in paticular $page._strippedContent which is only available in extendPageData - this is something that I had to deal with in vuepress-plugin-feed
  • overriding default $page.path with $page.frontmatter.permalink or $page.frontmatter.autometa.path seems the best option in this case; requires updating the PLUGIN.get_canonical_url()

webmasterish avatar Feb 27 '19 17:02 webmasterish

Only autometa is added. Permalink is built into the core. my config is here

// theme/index.js
const autometa_options = {
  canonical_base: 'https://example.com'
}
module.exports = {
  plugins: [
    [ 'autometa', autometa_options ]
  ]
}
  • using your temporary solution of using the ready hook function would not be enough to get all $page properties, in paticular $page._strippedContent which is only available in extendPageData - this is something that I had to deal with in vuepress-plugin-feed

It was very helpful. Thank you.

I agree. Because there are times when there are variables in the permalink'/:year/:month/:day/:slug', I think that it is better to use the getPermalink method of shared-utils.

tmiame avatar Feb 27 '19 19:02 tmiame

Thanks for clarifying it.

I'll take a look and see if it can be implemented and the best way to do so.

webmasterish avatar Feb 28 '19 20:02 webmasterish

#8 would fix this

tjventurini avatar Apr 25 '20 01:04 tjventurini