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

Somehow sync repo README and doc index.md? #73

Closed
tpolecat opened this issue Oct 26, 2016 · 11 comments
Closed

Somehow sync repo README and doc index.md? #73

tpolecat opened this issue Oct 26, 2016 · 11 comments

Comments

@tpolecat
Copy link

I'm finding that I want my repo's README and the index page for my microsite to be the same modulo front matter. This would be easy to hack up … would this be useful or am I just being weird?

@juanpedromoreno
Copy link
Member

Hey, thanks for mentioning it. If I didn't misunderstood, actually that functionality is already implemented. For example:

https://github.com/typelevel/cats/blob/master/build.sbt#L138
https://github.com/typelevel/scala/blob/typelevel-readme/build.sbt#L12

You could ignore the index.md file that is automatically copied to the docs folder (since it'll be copied each time you call makeMicrosite and maybe it doesn't make sense to commit it):

https://github.com/typelevel/cats/blob/master/.gitignore#L22

@tpolecat
Copy link
Author

Oh right, perfect. That's it! 👍

@tpolecat
Copy link
Author

Well. Not quite. Because it has no front matter it doesn't get included in the site. I'll think about it. No need to reopen.

@gpampara
Copy link

gpampara commented Dec 3, 2016

@tpolecat I just had the same issue and solved it, crudely, as follows:

  1. Use micrositeExtraMdFiles to copy the README.md file to a file called README.content
  2. Create an index.md in the src/main/tut directory, which then contains the YML front-matter, with a liquid template for jekyll that simply includes the content of the content of README.content in the file. The resulting index.md is then something like:
---
layout: home
title: "Home"
section: "home"
---

{% include_relative README.content %}

It's perhaps not the cleanest solution, but at least I can get my readme content into the site without too much complication.

@juanpedromoreno
Copy link
Member

Thanks @gpampara for sharing it!

Do you think we could automate it somehow?

@gpampara
Copy link

gpampara commented Dec 3, 2016

I guess one could automate this. This would mean that the README would become the main page of the site though? Good? Bad?

It works well for my use at the moment and I don't really see any glaring downsides, but I guess the option to override this behaviour would be reasonable. Suppose this would warrant another config option? Or it could be that if the user provides an index.md, then the behaviour of using the README would be disabled?

@tpolecat
Copy link
Author

tpolecat commented Dec 4, 2016

An option to make the repo README become the landing page for the site sounds great to me. Until then I may use @gpampara's hack. Thanks Gary!

@tpolecat
Copy link
Author

tpolecat commented Dec 4, 2016

Reopening because it seems like a thing.

@tpolecat tpolecat reopened this Dec 4, 2016
@juanpedromoreno
Copy link
Member

What do you think if we rewrite the extra md file configuration in the following way?

case class ExtraMdFileConfig(fileName: String, layout: String, metaProperties: Map[String, String] = Map.empty)

val micrositeExtraMdFiles = settingKey[Map[File, ExtraMdFileConfig]](
    "Optional. The key is related with the source file, the map value corresponds with the target relative file path and the document meta-information configuration. This key is useful for those document files that are located in a different places from the tutSourceDirectory. By default, it's empty")

// Example:
micrositeExtraMdFiles := Map(
	file("README.md") -> ExtraMdFileConfig("index.md", "home"),
	file("CONTRIBUTING.md") -> ExtraMdFileConfig("contributing.md", "page", Map("title" -> "Contributing", "section" -> "contributing", "position" -> "5")),
)

This configuration might generate the following files (in the docs folder):

  • index.md:
---
layout: home
---

<README.md contents>
  • contributing.md:
---
layout: page
title: Contributing
section: contributing
position: 5
---

<CONTRIBUTING.md contents>

Does it make sense?

@gpampara
Copy link

gpampara commented Dec 4, 2016

Yeah, that's a decent and reasonable approach. Keeps it consistent with the rest of the page definitions.

@gpampara
Copy link

The new scheme works well, thanks :)

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