Enveloppe / template-overrides

Please, follow this repo to get the update for template!
GNU General Public License v3.0
28 stars 1 forks source link

[Bug]: Broken links, made with DataviewJS #8

Open skroink opened 5 months ago

skroink commented 5 months ago

Material General discussion

Error

There's no error

Bug description

I'm trying to make a wiki-style infobox which autogenerates people data from properties, such as birth, date, filial relations, etc. The problems I'm experiencing is, whenever I publish a page with links made using dataviewjs, that either contains spaces or is direct relation to a page, then the link is broken on the published page. It seems like the links are not referenced properly in the output, and just appends to the current url.

Steps to reproduce

  1. Create 3 note "Characters/John Doe", "Characters/Jane Doe" and "Characters/Janie"
  2. Create 1 note "Dates/1960"
  3. Paste the following into John Doe
    
    ---
    Birth: "[[1960]]"
    Siblings:
    - "[[Jane Doe]]"
    - "[[Janie]]"
    ---
    #### These links work as intended
    - `$= dv.fileLink(dv.page(this.current().Birth).file.name)`
    - `$= dv.fileLink("1960")`
    - `$= dv.current().Siblings[1]`

These links appends to the url, and results in a 404

Expected behavior

All the links should be static url's, instead of being relative url's.

Screenshots

No response

Additional context

No response

Requirements

mkdocs==1.5.3
mkdocs-material==9.5.8
mkdocs-ezlinked-plugin==0.3.3
mkdocs-awesome-pages-plugin==2.9.2
mdx_breakless_lists==1.0.1
mkdocs-embed-file-plugins==2.0.9
mkdocs_custom_fences==0.1.2
mkdocs-git-revision-date-localized-plugin==1.2.4
mkdocs-encryptcontent-plugin==3.0.3
mkdocs-callouts==1.10.0
mkdocs-custom-tags-attributes==0.3.3
mkdocs-meta-descriptions-plugin==3.0.0
mkdocs-glightbox==0.3.7
obsidiantools==0.10.0
pyvis==0.3.2
cairosvg==2.7.1
pillow==10.2.0

Mkdocs.yml

site_name: Pendragon Notes # Change this to your site name
site_description: Obsdian notes
site_url: http://skroink.github.io/pendragon-notes # Change this to your site URL
site_author: skroink

theme:
    name: 'material'
    logo: assets/meta/favicons.png
    favicon: assets/meta/favicons.png
    custom_dir: overrides
    font:
        text: Ubuntu
        code: Ubuntu Mono
    language: en
    palette:

    # Light mode
    - media: "(prefers-color-scheme: light)"
      scheme: default
      primary: teal
      accent: light blue
      toggle:
        icon: material/toggle-switch-off-outline
        name: Switch to dark mode

    # Dark mode
    - media: "(prefers-color-scheme: dark)"
      scheme: slate
      primary: blue
      accent: indigo
      toggle:
        icon: material/toggle-switch
        name: Switch to light mode
    features:
        - navigation.indexes
        - navigation.top
        - navigation.tabs
        - navigation.tabs.sticky
        - navigation.expand
        - search.suggest
        - search.highlight

# Extensions
markdown_extensions:
  - footnotes
  - nl2br
  - attr_list
  - sane_lists
  - meta
  - smarty
  - tables
  - mdx_breakless_lists
  - def_list
  - pymdownx.arithmatex:
      generic: true
  - pymdownx.details
  - pymdownx.magiclink
  - pymdownx.critic
  - pymdownx.caret
  - pymdownx.keys
  - pymdownx.mark
  - pymdownx.tilde
  - pymdownx.highlight:
      use_pygments: true
      anchor_linenums: true
  - pymdownx.tasklist:
       custom_checkbox: true
  - pymdownx.emoji:
      emoji_index: !!python/name:material.extensions.emoji.twemoji
      emoji_generator: !!python/name:material.extensions.emoji.to_svg
  - admonition
  - toc:
      permalink: true
  - pymdownx.inlinehilite
  - pymdownx.snippets
  - pymdownx.superfences:
      custom_fences:
        - name: mermaid
          class: mermaid
          format: !!python/name:pymdownx.superfences.fence_code_format
plugins:
  - search
  - meta-descriptions
  - git-revision-date-localized:
      type: date
      fallback_to_build_date: true
      locale: en
      custom_format: "%A %d %B %Y"
      enable_creation_date: true
  - ezlinks:
        wikilinks: true
  - awesome-pages
  - embed_file:
      callouts: true
      custom-attributes: 'assets/css/custom_attributes.css'
  - custom-attributes:
      file: 'assets/css/custom_attributes.css'
  - tags:
      tags_file: tags.md
  - encryptcontent:
      title_prefix: '🔐'
      summary: 'Private page'
      placeholder: 'Password'
      decryption_failure_message: 'Invalid password'
      encryption_info_message: "You don't have access to this page."
      search_index: 'encrypted'
      password_button: True
      password_button_text: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" height="1em" width="1em"><!--! Font Awesome Pro 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M416 32h-64c-17.67 0-32 14.33-32 32s14.33 32 32 32h64c17.67 0 32 14.33 32 32v256c0 17.67-14.33 32-32 32h-64c-17.67 0-32 14.33-32 32s14.33 32 32 32h64c53.02 0 96-42.98 96-96V128C512 74.98 469 32 416 32zM342.6 233.4l-128-128c-12.51-12.51-32.76-12.49-45.25 0c-12.5 12.5-12.5 32.75 0 45.25L242.8 224H32C14.31 224 0 238.3 0 256s14.31 32 32 32h210.8l-73.38 73.38c-12.5 12.5-12.5 32.75 0 45.25s32.75 12.5 45.25 0l128-128C355.1 266.1 355.1 245.9 342.6 233.4z"/></svg>'
  - callouts
  - glightbox
hooks:
  - overrides/hooks/on_page_markdown.py
  - overrides/hooks/on_env.py
  - overrides/hooks/on_files.py
extra_javascript:
  - https://cdn.jsdelivr.net/gh/ObsidianPublisher/assets@main/dist/javascript.js
  - https://polyfill.io/v3/polyfill.min.js?features=es6
  - https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
extra_css:
    - https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css
    - https://cdn.jsdelivr.net/gh/ObsidianPublisher/assets@main/dist/styles.css
    - assets/css/admonition.css
    - assets/css/custom_attributes.css
    - assets/css/customization.css
    - stylesheets/infobox.css
    - stylesheets/tables.css
extra:
  SEO: assets/meta/SEO.png
  comments: False #disable comments globally
  generate_graph: True #generate the graph of the site
  attachments: 'assets/img' #path to the folder where the attachments are stored
  no-auto-h1: False #disable the automatic generation of h1 if no h1 is found
  blog_list:
    pagination: true #enable pagination
    pagination_message: true #display the message "Showing x posts out of y"
    pagination_translation: 'posts in' #message to display before the number of posts ; Add your own translation!
    no_page_found: "No pages found!" #message to display when no pages are found ; Add your own translation!
  hooks:
    strip_comments: true
    fix_heading: true
Mara-Li commented 5 months ago
  1. It seems to be an issue with the Plugin, not the template
  2. Did you check the dataview transformation in the settings ?
  3. Can I get the input and output file ?
skroink commented 5 months ago
  1. Sorry, wasn't sure where to report the issue, since it was an issue relating to multiple reposititories.
  2. Which settings are you refering to?

Input file

---
Birth: "[[1960]]"
Siblings:
  - "[[Jane Doe]]"
  - "[[Janie]]"
---
#### These links work as intended
- `$= dv.fileLink(dv.page(this.current().Birth).file.name)`
- `$= dv.fileLink("1960")`
- `$= dv.current().Siblings[1]`

#### These links appends to the url, and results in a 404
- `$= dv.current().Birth` 
- `$= dv.current().Siblings[0]`

Output file

---
Birth: "[[1960]]"
Siblings:
  - "[[Jane Doe|Jane Doe]]"
  - "[[Janie|Janie]]"
---
#### These links work as intended
- [1960](1960)
- [1960](1960)
- [Janie](Characters/Janie.md)

#### These links appends to the url, and results in a 404
- [1960](Events And Dates/1960.md) 
- [Jane Doe](Characters/Jane Doe.md)
Mara-Li commented 5 months ago

So, it seems that the path created by Dataviewjs is "malformed" and Mkdocs doesn't found them.

I don't know if it's a problem with dataviewJS direcly, Mkdocs or my plugin that doesn't transform the link from dataviewJS specially…

To be honest, I'm not surprised by these bug with Dataview. As I stated in some issue (also on Dataview), it's impossible to update the API, and Dataview is in maintenance mode. We don't have reply of the author at this time.

The conversion for dataviewjs is pretty difficult, and I don't plan to update it.

As a test, could you try to use Obsidian digital garden (another plugin) with these note, to check if this links render ?

skroink commented 5 months ago

That's a shame, Guess I need to reduce some complexity then. Thanks for responding quickly though! I tried setting it up via. Digital Garden, but it sadly it's worse there, it doesn't even render the links made using dataview, unless it's made with clear text.

Mara-Li commented 5 months ago

Ouch, at last my plugin does some cool things :D. I hope you will find some solution.

skroink commented 5 months ago

I'll find some way to work around it :) Great plugin, and works like a charm.