Giter Club home page Giter Club logo

Comments (2)

ofek avatar ofek commented on June 15, 2024 1

That hook works beautifully, thank you very much!

from mkdocs-material.

squidfunk avatar squidfunk commented on June 15, 2024

Thanks for suggesting. Insiders already allows to change many attributes for the default social card layouts by using the on_page_markdown hook, which deliberately uses a "latest" event priority to allow other plugins and hooks to change metadata before the social card is queued up for rendering. Moving rendering to on_page_content might be possible, but the problem is that the _title_from_render might contain markup, which will jam the social plugin.

Sticking to the title MkDocs derives before rendering is safe in regards to that it does not contain markup. Also note, that there are currently issues with title handling in MkDocs:

It seems that it was fixed, but we're still awaiting a release. We can re-evaluate this request once the changes are finally released, because it is unclear whether the title from rendering can "just be used" due to the potential presence of markup or unresolved icon short codes. Until then, here's a self-contained minimal reproduction that showcases how to change attributes for social cards programmatically in on_page_markdown for demo purposes:

social-card-title-hook.zip

Additionally, to work around the problem manually, you can use the following metadata in your page:

---
social:
  cards_layout_options:
    title: My page social card title
---

# My page title

Closing as resolved with configuration change.

from mkdocs-material.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.