squidfunk / mkdocs-material

Documentation that simply works
https://squidfunk.github.io/mkdocs-material/
MIT License
20.02k stars 3.46k forks source link

`Giscus` support with `privacy` plugin #3662

Closed ZhiyuanChen closed 2 years ago

ZhiyuanChen commented 2 years ago

Contribution guidelines

I've found a bug and checked that ...

Description

Giscus is not usable when enabling privacy plugin

Expected behaviour

pass

Actual behaviour

/zh-CN/widget?origin=https%3A%2F%2Fzhiyuanchen-project-zyc-ai-blog-rp79-8000.githubpreview.dev%2F%23activities&session=&theme=dark&reactionsEnabled=1&emitMetadata=1&inputPosition=top&repo=zyc-ai%2Fblog&repoId=MDEwOlJlcG9zaXRvcnk5OTQ5NTIwMg%3D%3D&category=General&categoryId=DIC_kwDOBe4tIs4CBXji&description=The+website+of+Zhiyuan+Chen&term=index
            HTTP/1.1" code 404

Steps to reproduce

pass

Package versions

Configuration

pass

System information

pass

squidfunk commented 2 years ago

Thanks for reporting. I think we should add an exclusion list for the plugin, so scripts and/or domains can be excluded. Giscus self-hosting is challenging and needs more work than just inlining the script.

squidfunk commented 2 years ago

I've added exclusion patterns in 36af41a. You can now specify Unix-style file name patterns which are matched against all external scripts to determine whether a script should be excluded from being bundled, and thus left as-is. In order to exclude Giscus and MathJax from bundling, you can use the following configuration:

  - privacy:
      externals_exclude:
        - cdn.jsdelivr.net/npm/mathjax@3/*
        - giscus.app/*

I'll add documentation for this new feature tomorrow and issue a new release, but it's already usable on master. Also note that running MkDocs in verbose mode will report all excluded assets: mkdocs build -v

squidfunk commented 2 years ago

I've also updated the JSON schema in a2f84565c.

squidfunk commented 2 years ago

Documentation was added in 1d9d6782d. I'll issue a new Insiders release later this day.

squidfunk commented 2 years ago

Released as part of 8.2.5+insiders-4.11.0.