xref: /plugin/combo/action/autofrontmatter.php (revision 4cadd4f8c541149bdda95f080e38a6d4e3a640ca)
1<?php
2
3use ComboStrap\Page;
4
5/**
6 * Copyright (c) 2021. ComboStrap, Inc. and its affiliates. All Rights Reserved.
7 *
8 * This source code is licensed under the GPL license found in the
9 * COPYING  file in the root directory of this source tree.
10 *
11 * @license  GPL 3 (https://www.gnu.org/licenses/gpl-3.0.en.html)
12 * @author   ComboStrap <support@combostrap.com>
13 *
14 *
15 * @deprecated - the frontmatter is no more used to enter metadata.
16 */
17class action_plugin_combo_autofrontmatter extends DokuWiki_Action_Plugin
18{
19
20
21    public function register(Doku_Event_Handler $controller)
22    {
23        /**
24         * Called when new page is created
25         * In order to set its content
26         * https://www.dokuwiki.org/devel:event:common_pagetpl_load
27         */
28        if (false) {
29            $controller->register_hook('COMMON_PAGETPL_LOAD', 'BEFORE', $this, 'handle_new_page', array());
30        }
31    }
32
33    public function handle_new_page(Doku_Event $event, $param){
34
35        $page = Page::createPageFromGlobalDokuwikiId();
36        $canonical = $page->getCanonicalOrDefault();
37        $event->data["tpl"] = <<<EOF
38---json
39{
40    "canonical":"{$canonical}",
41    "title":"A [[https://combostrap.com/frontmatter|frontmatter]] title shown on the Search Engine Result Pages",
42    "description":"A [[https://combostrap.com/frontmatter|frontmatter]] description shown on the Search Engine Result Pages"
43}
44---
45EOF;
46
47
48    }
49}
50
51
52
53