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

how to display the author and create time in every md page? #750

Closed
Jasyl0519 opened this issue Jan 17, 2019 · 11 comments
Closed

how to display the author and create time in every md page? #750

Jasyl0519 opened this issue Jan 17, 2019 · 11 comments

Comments

@Jasyl0519
Copy link

No description provided.

@Edgar-Spiir
Copy link

Edgar-Spiir commented Jan 21, 2019

Not sure about the author, but you can add the date when the file was modified, by adding date format to the docsify config

window.$docsify = {
	formatUpdated: '{YYYY}-{MM}-{DD}',
	...
}

and then using {docsify-updated} inside the markdown page.

More in docs: https://github.com/docsifyjs/docsify/blob/master/docs/configuration.md#formatupdated

@timaschew
Copy link
Member

You can define the author via front matter and then use a docsify plugin to access the author property and render it where you want.

@jthegedus
Copy link
Contributor

@timaschew an example doing so with the front-matter plugin would go a long way as it's not clear how that plugin is to be used.

@timaschew
Copy link
Member

Okay let's improve the documentation for that plugin.
Do you have some concrete questions?

@jthegedus
Copy link
Contributor

jthegedus commented Jan 24, 2019

I used it briefly and looked through the code and it strips the front-matter successfully, but it's not clear where the attributes end up.

vm.frontmatter = attributes;

how to we get this vm.frontmatter data in further plugins or our pages?

@timaschew
Copy link
Member

Yes that was also my initial question. But then after I saw the page about writing a plugin I've realized that the vm is passed to the plugin function.

I guess you would need to write in your markdown something like {{author}} and then in the beforeHook you can do something like

content.replace(/{{(.*)}}/g, function(match, group) {
  return vm.frontmatter[group]
})

But I think it makes sense to setup a convention for variables in general in docsify and provide to replace them by frontmatter attributes and implement it into the docsify core.

@jthegedus
Copy link
Contributor

Ah okay, a working example people could look at would go a long way here. I fear many people would overlook using docsify because front matter does not work as people would expect.

I do agree that

a convention for variables in general in docsify and provide to replace them by frontmatter attributes and implement it into the docsify core

would go a long way and remove most of my concerns with this plugin 😄

@timaschew
Copy link
Member

see #758

@BinaryPaean
Copy link

I can't even figure out how to activate front-matter to simply prevent YAML frontmatter in my 'README.md' from polluting the docsify site.

I've tried variations of:

window.$docsify = { frontMatter: true }
window.$docsify = { front-matter: true }
windows.$docsify = { front-matter: 'README.md' }
...

With no success. Can anyone point me at basic usage?

@szkiba
Copy link

szkiba commented Feb 4, 2020

You can substitute variables with docsify-mustache plugin using mustache syntax {{variable}}. Variables can be defined in front matter, external JSON|XML files or in docsify configuration.
If you use front-matter plugin, then the front matter variables will be available. Here is a demo using front matter:
https://docsify-mustache.github.io/#/?id=front-matter

@stale
Copy link

stale bot commented Apr 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

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

6 participants