nimib-land / nblog

✍️🐳👑 blog about nimib and nim ecosystem
https://nimib-land.github.io/nblog
MIT License
10 stars 0 forks source link

Generates nblog from a template github repo #12

Closed dlesnoff closed 1 year ago

dlesnoff commented 1 year ago

In Github, you have the possibility to generate a github repository from a template repository. Maybe you could make the inner structure of your blog (With a basic index.nim, index.html) file, available as a Github template repository, so that we can make easily a blog similar to yours ? Obviously, with much less theming than yours, so that we don't have all identical blogs ;) (and with a link to your blog, so that you get the credits).

pietroppeter commented 1 year ago

I would be happy to do that, although this nblog is probably not the best example. it basically has no theming apart from default nimib theme, and the only thing of (dubious) value is the index.nim. I do plan to work on a site generator with nimib with main use case blogs (and this will blog will move there as soon as it is ready).

For a similar idea see https://github.com/HugoGranstrom/nimib-playground by @hugogranstrom (actually inspired by you :)). It has no index but I guess it could be added.

HugoGranstrom commented 1 year ago

In Github, you have the possibility to generate a github repository from a template repository. For a similar idea see https://github.com/HugoGranstrom/nimib-playground by @HugoGranstrom (actually inspired by you :)). It has no index but I guess it could be added.

I'm still testing this idea and haven't implemented all things yet (a somewhat nice index file for example). Something I'm wondering about with Github templates: say that we do an update to the template. Isn't it more cumbersome for someone to merge those updates into their own repo if we do it as a template instead of a fork? As far as I understand it, a template doesn't come with all the history of a repo that a fork would.

dlesnoff commented 1 year ago

I am surprised to see that I have been quoted in the README of a project :) I like the simple nimble tasks of Hugo. We could add a configuration file to add options for :

  1. Dark theme in the template.
  2. Latex enabled by default.
  3. Select the form of the folder title (Add or not date and title). @HugoGranstrom Finally, you could add a nbText block with a h1 md header with the folderPrefix as a file title. I would change in your newNimib task:
    
    import std/[strutils, strformat]
    [...]
    writeFile("drafts" / folderName / "index.nim", """
    import nimib

nbInit

nbText:hlMd""" {folderPrefix} {'-'.repeat(folderPrefix.len)} """" nbSave """)


I think it would be preferable to add the starting Nimib template in an external file.

There could be a task to simply clean the folder when cloned from Hugo repo or you could publish the repo with empty draft folder to nimble, so that you just have to install the nimble pkg with nimble develop nimib-playground.

I plan to modify the index.nim just a little bit to add both a new nim and html file to the git, but otherwise, it scans the whole directory and makes what I wish.

In the future, once I become more familiar with HTML/CSS/Javascript, I will probably make something more customized.
I don't know much about Github templates, but you could check https://github.com/treeform/nimtemplate

I guess anyone can fork your template and then sync with your template when you make changes.
But it will probably not update every repositories depending on your template with the additions you make (It is safer so anyway).
A template is made to kickstart a Github project, not to change plenty of them at once.
HugoGranstrom commented 1 year ago

I am surprised to see that I have been quoted in the README of a project :)

Say good things and people will quote you ;)

Select the form of the folder title (Add or not date and title).

The date is there as a way to make each folder-name unique and avoid conflicts if (when) you have a bad imagination to come up with a new name for a nimib. But could absolutely make it an option that is on by default, but you can opt-out if you want a specific nimib to have a nicer url.

I think it would be preferable to add the starting Nimib template in an external file.

Yes, this solves many of the points I didn't reply directly to. This way we don't have to have too many options as you can just change it yourself. The only thing that we would need is a way to define pass the folderPrefix to that file. Perhaps as a compile options -d:nbFolderPrefix="coolName" internally?

There could be a task to simply clean the folder when cloned from Hugo repo or you could publish the repo with empty draft folder to nimble, so that you just have to install the nimble pkg with nimble develop nimib-playground.

Just delete the folder, no task needed :stuck_out_tongue_winking_eye: On a more serious note: the plan is to have a clean template for people to clone with empty folders, but that comes when I "release" this officially. I don't see how making it a nimble package would be useful tbh :thinking: This isn't a package, merely a template with some useful commands (which happens to be done using nimble).

I plan to modify the index.nim just a little bit to add both a new nim and html file to the git, but otherwise, it scans the whole directory and makes what I wish.

Yes, that's the nice thing with this approach that you can modify everything to your liking :)

In the future, once I become more familiar with HTML/CSS/Javascript, I will probably make something more customized.

I wouldn't consider myself particularly good at any of them, especially not CSS, but if I just do it in small pieces at a time it is actually not toooooooo hard. For example, starting with changing one specific element at a time instead of trying to do a super-duper-fancy-pancy cool new theme at once. But mostly it just involves trying to come up with a good phrase to search for on google/startpage/duckduckgo which gives the answer :rofl:

I guess anyone can fork your template and then sync with your template when you make changes. But it will probably not update every repositories depending on your template with the additions you make (It is safer so anyway). A template is made to kickstart a Github project, not to change plenty of them at once.

That's a good point, you can actually fork a template as well :O And most of the changes that I would introduce are limited to a few files, so manually updating them by copy-pasting wouldn't be too hard even if you choose to use the template instead.

pietroppeter commented 1 year ago

We could add a configuration file

note that nimib can easily give access to custom sections in nimib.toml (for an example of use see nimibook), e.g.:

[playground]
useLatex = true
useDark = true
folderName = "{{folderPrefix}}-{{date}}"

and I would move this discussion can probably be moved in nimib-playground repo :)

dlesnoff commented 1 year ago

Yes I started a discussion in the wrong place. Thanks for the .toml example. I close the issue then.