SimpleTOC – 能產生內容目錄的區塊

外掛說明

In Gutenberg, add a block and search for “SimpleTOC” or just “TOC”. You need to save your post before you add the block. It works by parsing the post content and retrieving the heading blocks and creates a new dynamic block with a list of links to the headings.

Hide the headline “Table of Contents” and set a maximum display depth in the blocks’ sidebar configuration. Add the CSS class “simpletoc-hidden” to a heading block to remove that specific heading from the generated TOC.

Features

  • No javascript or css added.
  • Designed for Gutenberg.
  • Compatible with AMP plugins.
  • Minimal and valid HTML output.
  • Inherits the style of your theme.
  • Support for column block layouts.
  • Control the maximum depth of the headings.
  • Choose between an ordered and unordered html list.
  • SEO friendly: Disable the h2 heading of the TOC block and add your own.
  • Comes with English, French, Spanish, German, and Brazilian Portuguese translations.
  • Works with non-latin texts. Tested with Japanese and Arabic.
  • 支援 Rank Math。

Credits

This plugin is forked from https://github.com/pdewouters/gutentoc by pdewouters and uses code from https://github.com/shazahm1/Easy-Table-of-Contents by shazahm1

Many thanks to Tom J Nowell https://tomjn.com and and Sally CJ who both helped me a lot with my questions over at wordpress.stackexchange.com

螢幕擷圖

  • SimpleTOC block in Gutenberg editor.
  • SimpleTOC in the post.
  • Simple but powerful. Customize each TOC as you like.
  • Control the maximum depth of the headings.

適用於區塊編輯器

這個外掛提供 1 個可供 Gutenberg/區塊編輯器使用的區塊。

  • SimpleTOC

安裝方式

SimpleTOC can be found and installed via the Plugin menu within WordPress administration (Plugins -> Add New). Alternatively, it can be downloaded from WordPress.org and installed manually…

In Gutenberg, add a block and search for “SimpleTOC” or just “TOC”. Please save your content before you use the block.

常見問題集

Why did you do this?

Because I needed a simple plugin to do this job and decided to do it on his own. I believe that a Table of Contents does not need Javascript and additional css. Furthermore the plugin should work out-of-the-box without any configuration.

How do I change the TOC heading ‘Table of contents’ to some other words?

Hide the headline in the sidebar options of SimpleTOC and add your own heading.

How do I add SimpleTOC to all articles automatically?

I don’t see an easy solution at the moment. SimpleTOC is only a block that can be placed in your post. If there would be a plugin that adds blocks to every post then this would be the solution. I think this should be another separate plug-in to keep the code of SimpleTOC clean and … well, simple. Maybe someone knows of a plug-in that adds blocks automatically to all posts with some parameters and settings? What about site editing in WordPress? I think the core team is working on something like that. I will keep this post open. If I have gained more knowledge how to solve this I will add this feature.

How do I add a background color to SimpleTOC?

SimpleTOC is simple. It will never load JavaScript or CSS. But you can add custom CSS yourself to your theme:

.simpletoc {
    padding: 1em 2em;
    background: #bada55;
}

If you want to add a color including the headline, add a custom css class to the SimpleTOC block. Name it “toctoc” or something like that.

.toctoc {
    padding: 1em 1em;
    background: #bada55;
}

If you use that CSS it will add a colored background to the whole TOC including the heading.

使用者評論

2021 年 2 月 25 日
A simple and effective plugin that just works. You can't go wrong. Plus the author provides exceptional support.
2021 年 2 月 25 日
Very simple to use - even for a newbie like myself. Add 'SimpleTOC as a block to your WP page, and assign the headings on the page as you go. SimpleTOC pulls those headings into a neat Table of Contents, which hyperlinks and snaps to the heading section on the page. It also pulls in the styles from your theme, keeping a nice, consistent look. Excellent and speedy support from the dev too when an element of the plugin wasn't working on my site. Was all fixed within the hour! Stop looking at alternatives and install this plugin.
2021 年 2 月 19 日
Upgrade caused me a problem, reported it and support was almost instant. A new update with a fix was out within the hour. Terrific response.
2021 年 2 月 1 日
Simple TOC is a wonderful TOC plugin as it offers incredible navigation inside the posts and pages and it is also super compatible with the amp. Kudos to the developers and support team who have been prompt in attempting to resolve all doubts and issues of users. My best wishes and luck in their future endeavors.
閱讀全部 16 則使用者評論

參與者及開發者

以下人員參與了開源軟體〈SimpleTOC – 能產生內容目錄的區塊〉的開發相關工作。

參與者

SimpleTOC – 能產生內容目錄的區塊 外掛目前已有 8 個本地化語言版本。 感謝全部譯者為這個外掛做出的貢獻。

將 SimpleTOC – 能產生內容目錄的區塊 外掛本地化為台灣繁體中文版

對開發相關資訊感興趣?

任何人均可瀏覽程式碼、查看 SVN 存放庫,或透過 RSS 訂閱開發記錄

變更記錄

4.4.8

  • Feature: Added option to toggle absolute urls.

4.4.7

  • Fix: Heading ids won’t be added to all posts anymore.
  • Fix: Headings with attributes like align-center will now appear in your TOC.
  • Feature: Added option to replace ul tag with ol tag. This will add decimal numbers to each heading in the TOC.
  • Feature: Works in nested blockes. This means support for column block layouts.

4.3

  • Feature: Support for non-latin headlines. SimpleTOC now uses a character block list rather than an allow list.
  • Feature: Add the CSS class “simpletoc-hidden” to the heading block to remove it from the Table of Contents.

4.1.1

  • Feature: Experimental support for Arabic Text.

4.0

  • Feature: Added option to set maximum level of the headings.

3.9

  • Added Brazilian Portuguese translations to the translations. Thanks Ralden Souza!

3.5

  • Added support for Rank Math plugin.