AntonioLoureiro / VueJS.jl

Julia web app builder using Vue.js
Other
12 stars 3 forks source link

Improve Page control - Title and meta tags #99

Closed charlieIT closed 2 years ago

charlieIT commented 2 years ago

Proposed features

Struct changes

Added properties title and meta to Page.

When no title is provided, behaviour will be the same as currently, the browser will assume an IP or Domain based name for the page

mutable struct Page
    dependencies::Vector{WebDependency}
    components::Dict{String,Any}
    scripts::Vector{String}
    cookiejar::Dict{String, Any}
    globals::Dict{String, Any}

    meta::Vector{HtmlElement}
    title::Union{String, Nothing}
end

Meta tag helpers

Helper methods added to Core\Base.jl to simplify creation of <meta> HTMLElements.

meta(entry::Pair)
meta(entry::Dict)
meta(entries::Vector)
function vue_handler(req)
    return VueJS.response(
            VueJS.page(["Welcome"], 
            title="Teste", 
            meta=[VueJS.meta(Dict("charset"=>"utf-16")), VueJS.meta(Dict("name"=>"robots", "content"=>"noindex,follow"))]
            )
    )
end
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Teste</title>
  <meta charset="utf-16">
  <meta name="robots" content="noindex,follow">

  (...)