Skip to content
This repository was archived by the owner on Jun 20, 2025. It is now read-only.

Add a home page template using the latest posts block to 2019 - #20

Merged
youknowriad merged 3 commits into
masterfrom
add/homepage
Feb 18, 2020
Merged

Add a home page template using the latest posts block to 2019#20
youknowriad merged 3 commits into
masterfrom
add/homepage

Conversation

@youknowriad

Copy link
Copy Markdown
Contributor

This PR tries to add a home page showing the list of posts to the 2019 theme using the recent posts block.

@youknowriad youknowriad added the block-based theme A theme using HTML templates label Feb 17, 2020
@youknowriad
youknowriad requested a review from kjellr February 17, 2020 09:51
@youknowriad youknowriad self-assigned this Feb 17, 2020
<!-- wp:group {"align":"full","className":"site-content"} -->
<div class="wp-block-group alignfull site-content"><div class="wp-block-group__inner-container"><!-- wp:post-title /--><!-- wp:post-content /--></div></div>
<div class="wp-block-group alignfull site-content"><div class="wp-block-group__inner-container">
<!-- wp:latest-posts {"postsToShow":100,"displayPostContent":true,"displayPostDate":true} /-->

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm showing 100 posts now because pagination is not supported yet.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm also showing the excerpt, post date and title. Ideally, this would use a "Query" block where you could decide to show post comment count... (but the query block is not implemented yet).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Definitely should be a Query since we need to read from the query context. It's also why I don't think adding pagination support to latest posts is a great idea: WordPress/gutenberg#19969 (comment)

Comment thread twentynineteen-blocks/style.css
Comment thread twentynineteen-blocks/style.css
}

/* Latest posts block */
.wp-block-latest-posts li > a {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a great example of the things we should be absorbing in the block style work. cc @ItsJonQ @nosolosw.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One potential answer for this would be this proposal WordPress/gutenberg#20290

@kjellr kjellr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks good! Fully agree that this should be done with the Query block when it's ready... the latest posts block actually has some very different built-in styles:

Screen Shot 2020-02-17 at 3 52 44 PM

(Honestly, those original styles look like a bug, so I'll look into that later 😅)

Luckily for the moment, those styles aren't being inherited here. 😄 This PR pointed out that the default block styles like those are only being used if the block lives directly inside of an "approved" container such as .entry-content, .site-header, or .site-footer. This is fine for now, but the original Twenty Nineteen style.css file could probably use a refactor in another PR so that those styles are less specific.

In any case, I added some minor fixes, and I think this is good to go as a proof of concept. We can revisit when the query block is live.

@youknowriad
youknowriad merged commit 64a31e0 into master Feb 18, 2020
@youknowriad
youknowriad deleted the add/homepage branch February 18, 2020 08:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

block-based theme A theme using HTML templates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants