View Source PhoenixPages behaviour (phoenix_pages v0.1.1)

Blogs, docs, and static pages in Phoenix. Check out the README to get started.

options

Options

  • :otp_app - The name of the OTP application to use as the base directory when looking for page files. This value is required.

  • :render_options - Allows the renderers to be configured. See pages/4 for the options.

Link to this section Summary

Callbacks

Gets a list of pages for a given ID. See the :id option in pages/4.

Same as get_pages/1, but will raise PhoenixPages.NotFoundError if no pages were defined with the ID.

Functions

Finds all the pages matching a pattern and generates a GET route for each one.

Link to this section Types

Link to this section Callbacks

@callback get_pages(id :: atom() | binary()) :: {:ok, [page()]} | :error

Gets a list of pages for a given ID. See the :id option in pages/4.

This can be used to get a list of pages from within a controller for index pages or further customization such as finding related pages, filtering by a value, etc. Returns {:ok, pages} if successful, or :error if no pages were defined with the ID.

@callback get_pages!(id :: atom() | binary()) :: [page()]

Same as get_pages/1, but will raise PhoenixPages.NotFoundError if no pages were defined with the ID.

Link to this section Functions

Link to this macro

pages(path, plug, plug_opts, opts \\ [])

View Source (macro)

Finds all the pages matching a pattern and generates a GET route for each one.

options

Options

  • :id - The ID for this collection of pages so they can later be accessed with get_pages/1 and get_pages!/1. This is only required if using those functions.

  • :from - The wildcard pattern used to look for pages on the filesystem. Make sure the base directory is included in your release (priv is included by default). Defaults to priv/pages/**/*.md.

  • :sort - The order of the pages returned when using get_pages/1 and get_pages!/1. Defined as a tuple with the first element being an atom for the sort value (which can be any value from the attributes), and the second element being either :asc or :desc.

  • :attrs - A list of attributes used when parsing the markdown frontmatter for each page. Atoms will be required for each page, key values will be optional with a default value. Defaults to [].

  • :render_options - Allows the renderers to be configured. This can also be set globally in the module options.

    • :markdown - Allows the Earmark renderer to be configured.
      • :hard_breaks - Whether to convert hard line breaks to <br> tags. Defaults to false.
      • :wiki_links - Whether to enable wiki-style links such as [[page]]. Defaults to true.
      • :pure_links - Whether to convert raw URLs to <a> tags. Defaults to true.
      • :sub_sup - Whether to convert ~x~ and ^x^ to <sub> and <sup> tags. Defaults to true.
      • :footnotes - Whether to enable footnotes. Defaults to true.
      • :smartypants - Whether to enable smartypants. Defaults to true.
      • :compact_output - Whether to avoid indentation and minimize whitespace in output. Defaults to false.
      • :escape_html - Whether to allow raw HTML in markdown. Defaults to false.
      • :syntax_highlighting - Whether to enable Makeup syntax highlighting. Defaults to true.
      • :code_class_prefix - A class prefix to add to the language class of code blocks.
  • All other options are passed to Phoenix.Router.match/5