WordPress / wporg-main-2022

A block-based child theme for WordPress.org, plus local environment
62 stars 22 forks source link

Data Liberation: Add a data liberation handbook setup #374

Closed dd32 closed 5 months ago

dd32 commented 6 months ago

This PR adds the necessary things to the theme to support the import of the data liberation guides as a handbook.

See https://github.com/WordPress/data-liberation/pull/46 for the manifest it uses.

dd32 commented 6 months ago

I don't think cron tasks work correctly in the local environment, so you'll probably have to run them manually when required:

yarn wp-env run cli wp cron event run --due-now
dd32 commented 6 months ago

Just noting, if we want to commit/deploy this prior to resolving all style issues, and as a result have the /and/{guide} route not work for non-editors, we can disable it from loading with something like this:

add_filter( 'handbook_post_type_defaults', function( $args, $slug ) {
    if (
        'and' === $slug &&
        ! current_user_can( 'edit_handbook_pages' ) &&
        ! wp_doing_cron() &&
        ! ( defined( 'WP_CLI' ) && WP_CLI )
    ) {
        return false;
    }

    return $args;
}, 10, 2 );

Additionally, we probably also want to add a check in here that only loads it for not-rosetta sites, as we currently have no way to translate handbooks (which is a separate issue, and this is not going to resolve)

edit: in retrospect, just not enabling the handbook plugin on rosetta will result in that, so nevermind!

StevenDufresne commented 6 months ago

The only question I have is the url structure.

We currently have wp.org/data-liberation as the landing page.

I imagine we could change /data-liberation to /and so then we could have:

I don't know that the following reads that well:

However we do need the following:

So maybe it makes sense to make /data-liberation the root.

dd32 commented 6 months ago

Yeah I wasn't sure on that either :)

The good news is that we can change the base slug easily.

Currently the PR for the handbook simply sets w.org/and/ as a post type index, but as you've probably seen, creating a specific page in GitHub (welcome, index, handbook, or and-handbook) would place that at w.org/and instead. We probably don't want to use a specific page like that though, we probably just want the post-type archives and our custom landing pages.

Based on the WordPress/data-liberation contents, it might make sense to split it up into a few different "sections" of content, based on the intention of the underlying guide:

so something like: