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

front matter support #58

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

front matter support #58

wants to merge 23 commits into from

Conversation

juanolon
Copy link
Contributor

@juanolon juanolon commented Jun 12, 2024

By just including the frontmatter extension of goldmark, it removes the yaml header from the page when rendering the page. There still some issues, we need to work on (see discussion: #55 (reply in thread))

  • recent page
  • auto linking
  • title in template
  • tags
  • date

@emad-elsaid
Copy link
Owner

Nice, that's a good progress 😄 . autolinking is probably that one that will give you the most trouble

@juanolon
Copy link
Contributor Author

So, this is done so far. The following fields are supported: title, date and tags. date has the format time.DateOnly or time.DateTime. tags is a list of tags.

  • recent page respects the date field.
  • tags page also collect the tags from yaml
  • related pages load tags info
  • autocomplete works on title and tags
    and of course, frontmatter is optional ;) let me know i missed something :)

Copy link
Owner

@emad-elsaid emad-elsaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think changing Modtime to accept boolean has triggered many changes in this PR. I would like to think a bit about avoiding it

extensions/metadata/metadata.go Show resolved Hide resolved
extensions/metadata/metadata.go Show resolved Hide resolved
page.go Outdated Show resolved Hide resolved
page.go Outdated Show resolved Hide resolved
page.go Show resolved Hide resolved
@emad-elsaid
Copy link
Owner

After merging the other PRs it conflicted with this PR, I think there were duplicate changes between them

@juanolon
Copy link
Contributor Author

I think changing Modtime to accept boolean has triggered many changes in this PR. I would like to think a bit about avoiding it

Yes, at first i just changed to be like Title (if date is set, then use it, otherwise fallback to file modtime), but then i saw that Modtime is also used in preProcessedContent, which i think, it updates its internal p.content field if the file has change since ModTime. That's why i thought of adding this flag.
The other option i thought, was of adding a new field to the interface, but I didn't want to pollute the interface much.
Anyway, if you come with a better idea, or prefer the other idea, i would be glad to hear it.

@juanolon
Copy link
Contributor Author

juanolon commented Jul 1, 2024

Hey, I was thinking about making the regex change. It just occur to me, that reading line-by-line would be more efficient than opening the whole file for regex parsing.

Also, i was looking if there is any standard about the triple dash. It seems that it is indeed 3 dashes, and no more.

@emad-elsaid
Copy link
Owner

I still can't accept the fact that we have a lot of changed because we added an attribute to ModTime.
I think there could be a workaround.

  • The modified time we get from the system is accurate to the nanosecond.
  • the date we read from frontmatter doesn't need to have this accuracy
  • If we get the nanosecond from the file modtime and overwrite it in the one we read from the front matter the time changes when the file changes, but the display date/time won't.
  • This way we don't need to add this attribute
    I'll try to make this change

@@ -48,8 +54,39 @@ type Page interface {
Emoji() string
}

type Date struct {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to do multiple tries until a date worked, I think we need to support more date formats

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will look for a date parse library, which could be more flexible than the go standard library.

@emad-elsaid
Copy link
Owner

I noticed something is off with the hashtags
2024-07-07_00-48-47

@emad-elsaid
Copy link
Owner

We need to think about removing Title() and depending on Name() is there a usage for Name that you wanted to avoid changing so you had to introduce Title() ?

@juanolon
Copy link
Contributor Author

juanolon commented Jul 7, 2024

We need to think about removing Title() and depending on Name() is there a usage for Name that you wanted to avoid changing so you had to introduce Title() ?

I introduce Title() because Name() is used not just as the "name" of the page (link names, page title..) but also to generate the links (as the path of the page). So they are semantically different.

@juanolon
Copy link
Contributor Author

juanolon commented Jul 7, 2024

I noticed something is off with the hashtags 2024-07-07_00-48-47

the tag "2/4" is being shown multiple times? how can i reproduce it? how is the tag defined? using #tag and .meta.tags

@emad-elsaid
Copy link
Owner

I just ran xlog in its repository. this file is "index.md"

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

Successfully merging this pull request may close these issues.

None yet

2 participants