redwoodjs / redwoodjs-com-archive

Public website for RedwoodJS
https://redwoodjs.com
129 stars 156 forks source link

Tutorial: Several sections that used to be separate got merged into one #402

Closed cannikin closed 4 years ago

cannikin commented 4 years ago

I found two separate instances of sections getting merged together:

All got merged into Getting Dynamic.

All got merged into Saving Data

They all still have ## levels as headers, and build.js still says to break on heading levels [1, 2] so nothing there has changed.

@forresthayes @dom Do either of you remember a PR that tried to fix having # comments in code blocks (they were getting turned into section headers by mistake)? I'm wondering if that change caused this maybe? Update found the PR: https://github.com/redwoodjs/redwoodjs.com/pull/388

forresthayes commented 4 years ago

@cannikin I'm looking into it. Could this be related? https://github.com/redwoodjs/redwoodjs.com/commit/3cd4d98342c59f48b0518c2e9859b4879f2c8c53

cannikin commented 4 years ago

That's my guess... I found the PR and added a link in the first comment. @Tobbe any idea if that would be causing this?

cannikin commented 4 years ago

Yep, I reverted that commit locally and the sections are back. We definitely want this functionality though, we'll have to dig in and figure out what's blowing up that logic... it looks sound to me.

Maybe the tutorial has a syntax error where there's a missing ``` which would close a code block?

cannikin commented 4 years ago

Oh geez the left nav is all over the place...I just did a deploy with a couple small text changes to the tutorial and now different sections are grouped together!

I'm going to revert that commit until we can figure that out...the tutorial working is our #1 priority!

Tobbe commented 4 years ago

Sorry for causing all the trouble. I'll see if I can figure out why it's breaking

cannikin commented 4 years ago

No problem @Tobbe, it looked good to me too, I have no idea why it's freaking out! My guess is the tutorial itself has an extra something, or missing something, that's breaking it.

Tobbe commented 4 years ago

It's not the cause of this problem, but looking at the tutorial I found this

>
> ```javascript
> export const QUERY = gql`
>   query BlogPostsQuery {
>     postIds: posts {
>       id
>     }
>   }
> `
> ```
>
> Now `postIds` will be available in `Success` instead of `posts`

That's something my regexp wouldn't handle since it expects code blocks to start at the start of the line (^) On the other hand, if that code block contained a # it also wouldn't be detected as a heading to split a page at, so... don't worry about it?

Tobbe commented 4 years ago

Aha!

It's when you have a code block like this that it breaks

```plaintext{13-18}
// api/prisma/schema.prisma

model Post {
  id        Int      @id @default(autoincrement())
  title     String
  body      String
  createdAt DateTime @default(now())
}
```

My regexp doesn't handle the syntax for adding line highlights

cannikin commented 4 years ago

Edit Haha I was typing this as your response came in, we found it at the same time!

Just had a thought as I was doing something else: that regex has a \w* which won't match code blocks that have line number highlight hints:

```javascript{1,3}

But it will match the closing `` bracket. So I bet it's getting out of sync and counting some ``` as **opening** a code block, which then skips over the##` headers in some parts of the tutorial.

Tobbe commented 4 years ago

What about just making the regexp look for lines that start with three backticks? Can you think of any false positives?

cannikin commented 4 years ago

Yeah that should be fine, I'm pretty sure a line starting with those in markdown will always be code!

Tobbe commented 4 years ago

Cool, I'll make a new PR