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

Abstract file into class #436

Merged
merged 5 commits into from
Sep 30, 2023
Merged

Conversation

julesvirallinen
Copy link
Contributor

Abstracts file to class, it can compile itself and return things.

Ideally it would handle it's own metadata too, and the compiler could be less complex.

Then we can do

type TCompiler = (PublishFile) => string

and inside a compiler:

const icon = publishFile.meta.getIcon 

instead of stuff like this:

		const noteIconKey = this.settings.noteIconKey;

		if (baseFrontMatter[noteIconKey] !== undefined) {
			publishedFrontMatter["noteIcon"] = baseFrontMatter[noteIconKey];
		} else {
			publishedFrontMatter["noteIcon"] = this.settings.defaultNoteIcon;
		}

It COULD be that we'd want PublishFile to extend TFile. Also not 100% on the name PublishFile.

Copy link
Owner

@oleeskild oleeskild left a comment

Choose a reason for hiding this comment

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

I love this! This is a great abstraction.
I think it makes sense to not extend TFile, and instead keep it like it is now.
I can't think of a better name than PublishFile on the top of my head. It keeps the naming consistent, in that the obsidian API uses TFile. And I think it is easy to quickly grasp the concept when reading the code.

Could you rebase this on top of the current main branch? I'll merge it after.

src/ui/PublicationCenter.svelte Show resolved Hide resolved
@oleeskild oleeskild merged commit dae2ae7 into oleeskild:main Sep 30, 2023
4 checks passed
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.

2 participants