webmasterish / vuepress-plugin-autometa

Auto meta tags plugin for VuePress 1.x
MIT License
40 stars 6 forks source link

Permalink is not reflected #4

Open tmiame opened 5 years ago

tmiame commented 5 years ago

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

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

webmasterish commented 5 years ago

Thank you @tmiame for the feedback!

Here's what I think:

tmiame commented 5 years ago

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.

webmasterish commented 5 years ago

Thanks for clarifying it.

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

tjventurini commented 4 years ago

8 would fix this