-
Notifications
You must be signed in to change notification settings - Fork 27
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
API refactors #21
API refactors #21
Conversation
move IBlock to client.ts so it lives with IPageData. this reduces the naming surface area because `contents` always refers to rendered `StringOrTag[]` and `contentsRaw` is always a string.
…ngNode IPageNode extends IHeadingNode for maximal reuse (depth => level)
fix compiler testsPreview: docs |
|
||
/** Parsed nodes of source file. An array of rendered HTML strings or `@tag` objects. */ | ||
contents: StringOrTag[]; | ||
contentsRaw: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thoughts on content
vs contents
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmmmm i think i prefer to use plurals for arrays but singular for non arrays
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i definitely prefer consistency. either content
or contents
. i see no need to use them both in the same interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Want more split files i think
@@ -5,10 +5,32 @@ | |||
* repository. | |||
*/ | |||
|
|||
/** Slugify a string: "Really Cool Heading!" => "really-cool-heading-" */ | |||
export function slugify(str: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yay, client only!
* The basic components of a navigable resource: a "route" at which it can be accessed and | ||
* its depth in the layout hierarchy. Heading tags and hierarchy nodes both extend this interface. | ||
*/ | ||
export interface INavigable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
|
||
/** Parsed nodes of source file. An array of rendered HTML strings or `@tag` objects. */ | ||
contents: StringOrTag[]; | ||
contentsRaw: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmmmm i think i prefer to use plurals for arrays but singular for non arrays
depth: number; | ||
route: string; | ||
/* | ||
LAYOUT HIERARCHY NODES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these gigantic capitalized headers indicate to me that these should be a in a separate named "layoutHierarchy.ts" or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe in a client subdir with an index.ts
so you can import everthing you need
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm these are all pretty intertwined and it's nice having all the symbols in one file.
|
||
export type PartialPageData = Pick<IPageData, "absolutePath" | "contentRaw" | "contents" | "metadata">; | ||
export type PartialPageData = Pick<IPageData, "absolutePath" | keyof IBlock>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
language features!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah! tho this type is gonna go away in my next PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, skip the split
IPageData
extendsIBlock
, compiler methods also speakIBlock
contents
always refers to renderedStringOrTag[]
andcontentsRaw
is always a string.INavigable
for route & level used inIHeadingTag
&IHeadingNode
IPageNode
extendsIHeadingNode
for maximal reuse (also rename depth → level)any
arg & check existence first