Skip to content

Instantly share code, notes, and snippets.

@james2doyle
Created October 10, 2025 22:06
Show Gist options
  • Save james2doyle/62da26fdb006fde0faf08b31d02926b1 to your computer and use it in GitHub Desktop.
Save james2doyle/62da26fdb006fde0faf08b31d02926b1 to your computer and use it in GitHub Desktop.

Revisions

  1. james2doyle created this gist Oct 10, 2025.
    15 changes: 15 additions & 0 deletions generate-deep-slug-urls.groq
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    // since the argument variable can only be referenced once, we need this function repeated
    fn ex::p($p) = $p->{"c":url.current};
    fn ex::pp($p) = $p->{"c": ex::p(parentPage).c};
    fn ex::ppp($p) = $p->{"c": ex::pp(parentPage).c};
    // will output `level-4/level-3/level-2/level-1`
    // usage: { "href": ex::slug(@) }
    fn ex::slug($d) = $d{"slug":array::join(
    array::compact([
    ex::ppp(parentPage).c,
    ex::pp(parentPage).c,
    ex::p(parentPage).c,
    url.current
    ]),
    '/'
    )};