I am sorry, in fact, I had copied your code earlier, but it did not work. After reviewing your test code, I even copied the entire home.html to my index.html, but it still display all the articles.
I tried creating a /content/page/test/index.md, and added a test.html under layouts/page, and copied your code into it, it works well.
test.html
{{ $p1 := where site.RegularPages "Type" "in" site.Params.mainSections }}
{{ $p2 := where $p1 "Params.categories" "intersect" (slice "moments" "thinks") }}
{{ $p := $p1 | complement $p2 }}
<div class="article-list--compact">
{{ range $p }}
{{ partial "article-list/compact" . }}
{{ end }}
</div>
I am wondering if this issue is caused by the special settings of the theme, but I haven’t received a response yet after submitting an issue on GitHub.