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

Page Properties force overwrites markdown with existing YAML Page Metadata #1925

Open
sean-freeman opened this issue May 23, 2020 · 5 comments
Assignees

Comments

@sean-freeman
Copy link

Describe the bug
Upon importing Markdown from existing source, the Page Properties blank fields force overwrite of the imported markdown's existing YAML Page Metadata. This breaks usage of wiki.js for managing existing source materials from Jekyll "Front Matter" etc.

To Reproduce

  1. Import file
  2. Edit file
  3. Check git

Pre-Import of "test-page.md":

---
page: test-page
keywords: Test

lastupdated: "2019-01-18"
---

Post-Import of "test-page.md":

---
title: test-page
description: 
published: true
date: 2020-05-22T20:50:29.008Z
tags: 
---

Expected behavior
Existing keys are not over-written, and Wiki.js keys are optional (or prefixed with wikijs- ?

Host Info (please complete the following information):

  • OS: Ubuntu Docker Container
  • Wiki.js version: 2.2.51
  • Database engine: postgres 12.1
@RyanGreenup
Copy link

RyanGreenup commented Jun 2, 2020

This would also allow WikiJS to be compatible with Notable and so I'd love to see it.


This is quite related, I'm not sure if this should be it's own issue (if so I'll make a seperate issue), but perhaps the tags property should be modified to look like this:

---
tags: [tag1, tag2, tag3]
---
# My MD Note
content blah...

That way it would:

  1. Work with existing libraries
    • for example in R there is the rmarkdown::yaml_front_matter() function, this allows me to extract tags from markdown files, but without the square brackets it returns an error.
  2. Work with Notable which also expects the square brackets.

Better Cross compatability would be a welcome improvement.


edit: This tag feature is also missing from the beta so I made a new issue here

@sean-freeman
Copy link
Author

@regevbr Is this already covered by your recent PR for improving Page Properties?

@regevbr
Copy link
Contributor

regevbr commented Jul 17, 2020

Nope

@sean-freeman
Copy link
Author

sean-freeman commented Aug 20, 2020

@NGPixel do you agree with the following proposal to resolve this issue?

Metadata inject function:
https://github.com/Requarks/wiki/blob/dev/server/helpers/page.js#L68

  • Proposal: change let “meta”, with each array element using prefix wikijs_
  • Proposal: replace return with for loop on array elements, if found existing metadata in page.content then replace - else append new line with the metadata

Metadata read function:
https://github.com/Requarks/wiki/blob/dev/server/modules/storage/disk/common.js#L89

  • Proposal: change _.get to use prefixes such as wikijs_title, wikijs_description, wikijs_isPublished, wikijs_tags

If I've understood the inject function, it should have no impact on calls to Metadata inject function:

If I've understood the read function, it should have no impact on calls to Metadata read function:

@NGPixel
Copy link
Member

NGPixel commented Aug 20, 2020

@seafre No, existing fields should be preserved but Wiki.js fields shouldn't be prefixed. Not only that would break any page already using un-prefixed fields, it wouldn't make sense to have duplicate fields per application.

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

No branches or pull requests

4 participants