Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permalink is not reflected #4

Open
tmiame opened this issue Feb 27, 2019 · 4 comments
Open

Permalink is not reflected #4

tmiame opened this issue Feb 27, 2019 · 4 comments

Comments

@tmiame
Copy link

tmiame commented Feb 27, 2019

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!

@webmasterish
Copy link
Owner

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()

@tmiame
Copy link
Author

tmiame commented Feb 27, 2019

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
Copy link
Owner

Thanks for clarifying it.

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

@tjventurini
Copy link

#8 would fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants