squidfunk / mkdocs-material

Documentation that simply works

Home Page:https://squidfunk.github.io/mkdocs-material/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Autoloading not working properly

BennyDeBock opened this issue · comments

Contribution guidelines

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

  • ... the problem doesn't occur with the mkdocs or readthedocs themes
  • ... the problem persists when all overrides are removed, i.e. custom_dir, extra_javascript and extra_css
  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

I've been trying to lock down the CSP headers for a documentation website and for that i need my fonts loaded locally. I've added them to my assets folder and followed the steps found here to turn off google fonts loading: https://squidfunk.github.io/mkdocs-material/setup/changing-the-fonts/#autoloading. However, this does not seem to work as it still loads fonts from the index.ts.

image

Expected behaviour

Remove every reference to loading external fonts from google fonts and use the local ones.

Actual behaviour

Font loaded from google fonts is still included in the generated index.html head tag

image

Steps to reproduce

  1. clone https://github.com/vapor/docs/tree/enhancement/AddCSPHeaders locally
  2. install mkdocs requirements
  3. open the 4.0 folder
  4. run mkdocs serve

Package versions

  • Python: 3.10.2
  • MkDocs: 1.2.3
  • Material: 8.2.5

Configuration

# Project information
site_name: Vapor Docs
site_url: https://docs.vapor.codes/4.0/
site_author: Vapor Community
site_description: Vapor 4's documentation (web framework for Swift).

# Repository
repo_name: Vapor GitHub
repo_url: http://github.com/vapor/vapor
edit_uri: https://github.com/vapor/documentation/edit/main/4.0/docs/

# Copyright
copyright: "Copyright © Vapor Community"

# Configuration
theme:
  name: material
  custom_dir: theme/
  language: en
  locale: en

  palette:
    primary: black
    accent: blue
  
  logo: assets/logo.png
  favicon: assets/favicon.png

  features:
    - search.suggest
    - search.highlight

# Customization 
extra:
  # Font
  font: false

  # Social
  social:
    - icon: fontawesome/brands/twitter
      link: https://twitter.com/codevapor
    - icon: fontawesome/brands/discord
      link: https://discord.gg/vapor
    - icon: fontawesome/brands/github
      link: https://github.com/vapor

extra_css:
  - stylesheets/syntax.css
  - stylesheets/fonts.css

extra_javascript:
  - javascripts/syntax.js

# Extensions
markdown_extensions:
  - admonition
  - footnotes
  - meta
  - toc:
      permalink: true

# Plugins
plugins:
  - search:
      lang: en
  # i18n plugin documentation
  # https://github.com/ultrabug/mkdocs-static-i18n
  - i18n:
      default_language: 'en'
      search_reconfigure: false
      material_alternate: true
      # Add the new languages here. DON'T CHANGE THE DEFAULT LANGUAGE
      languages:
        en: 
          name: English
          build: true
        nl: 
          name: Nederlands
          site_name: Vapor Documentatie
          build: true
        fr:
          name: Français
          site_name: Documentation Vapor
          build: true
      # Add navigation translations here
      nav_translations:
        nl:
          Welcome: Welkom
        fr: 
          Welcome: Bienvenue


nav:
- Welcome: "index.md"
- Install:
  - macOS: "install/macos.md"
  - Linux: "install/linux.md"
- Getting Started:
  - Hello, world: "hello-world.md"
  - Folder Structure: "folder-structure.md"
  - SPM: "spm.md"
  - Xcode: "xcode.md"
- Basics:
  - Routing: "routing.md"
# TODO: Improve quality
# Mostly just a code sample with little explanation.
#  - Controllers: "controllers.md"
  - Content: "content.md"
  - Client: "client.md"
  - Validation: "validation.md"
  - Async: "async.md"
  - Logging: "logging.md"
  - Environment: "environment.md"
  - Errors: "errors.md"
- Fluent:
  - Overview: "fluent/overview.md"
  - Model: "fluent/model.md"
  - Relations: "fluent/relations.md"
  - Migrations: "fluent/migration.md"
  - Query: "fluent/query.md"
  - Transactions: "fluent/transaction.md"
  - Schema: "fluent/schema.md"
  - Advanced: "fluent/advanced.md"
- Leaf:
  - Getting Started: "leaf/getting-started.md"
  - Overview: "leaf/overview.md"
  - Custom Tags: "leaf/custom-tags.md"
- Redis:
  - Overview: "redis/overview.md"
  - Sessions: "redis/sessions.md"
- Advanced:
  - Middleware: "middleware.md"
  - Testing: "testing.md"
  - Server: "server.md"
  - Files: "files.md"
  - Commands: "commands.md"
  - Queues: "queues.md"
  - WebSockets: "websockets.md"
  - Sessions: "sessions.md"
  - Services: "services.md"
  - APNS: "apns.md"
- Security:
  - Authentication: "authentication.md"
  - Crypto: "crypto.md"
  - Passwords: "passwords.md"
  - JWT: "jwt.md"
- Deploy:
  - DigitalOcean: "deploy/digital-ocean.md"
  - Heroku: "deploy/heroku.md"
  - Supervisor: "deploy/supervisor.md"
  - Nginx: "deploy/nginx.md"
  - Docker: "deploy/docker.md"
- Version (4.0):
    - v1.5: "version/1_5.md"
    - v2.0: "version/2_0.md"
    - v3.0: "version/3_0.md"
    - v4.0: "version/4_0.md"
    - Upgrading: "upgrading.md"

System information

  • Operating system: Windows 10
  • Browser: Firefox 100.0

Thanks for reporting. You have a custom_dir set, so it could be that the problem lies within your customization. Please provide a minimal, reproducible example with a mint Material for MkDocs installation, and without customization and overrides and attach it here as a zip file. This is what I need to look into it.

Ah, wait, no, your configuration is wrong. You specified font: false under extra, but it must be located under theme:

theme:
  font: false

oh, sorry about that then. such an oversight. It works now!

Tip: Material for MkDocs provides a schema which you can easily set up in a few minutes that should catch such errors:
https://squidfunk.github.io/mkdocs-material/creating-your-site/#minimal-configuration

Bildschirmfoto 2022-05-09 um 15 31 44

Additionally, the privacy plugin might help you in creating a fully self-contained and self-hostable version of your documentation. Besides automatically downloading web fonts, it will also download external styles, scripts, images, etc.