<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>${metadata.alias!}${word?has_content?then(' - '+word,'')}</title>
    <meta name="keywords" content="<#list getKeywords(word) as a>${a}<#sep>,</#list>"/>
    <meta name="description" content="${site.name} - Search"/>
</head>
<body>
    <header>
        <form method="get">
            <input type="text" name="word" value="${word!}"/>
            <input type="submit" value="Search"/>
        </form>
    </header>
    <nav>
        <a href="${base}">Home</a>
<@_categoryList>
    <#list page.list as a>
        <a href="${a.url!}" target="_blank">${a.name}</a>
    </#list>
</@_categoryList>
    </nav>
    <main>
<#macro merge name value><#if !.vars[name]??><@"<#assign ${name}=''>"?interpret /></#if><#if value??><@"<#assign ${name}=${name}+'${value},'>"?interpret /></#if></#macro>
<@_search word=word tagId=tagId highlight=true pageIndex=pageIndex pageSize=10>
    <#if page.totalCount gt 0>
        <h1>Results</h1>
    <#list page.list as a>
        <@merge 'categoryIds' a.categoryId!/>
    </#list>
    <@_category ids=categoryIds><#assign categoryMap=map/></@_category>
    <#list page.list as a>
        <article>
            <h3>[<a href="${(categoryMap[a.categoryId?string].url)!}" target="_blank">${(categoryMap[a.categoryId?string].name)!}</a>]<a href="<#if a.onlyUrl>${site.dynamicPath}content/redirect?id=${a.id}<#else>${a.url!}</#if>" target="_blank">${a.title?no_esc}</a></h3>
            <p>
                <#if a.cover?has_content><img src="${a.cover}" alt="${a.title}"/></#if>
                ${(a.description?no_esc)!}
            </p>
        </article>
    </#list>
        <div>
            <#if !page.firstPage>
                <a href="?word=${word!}&tagId=${tagId!}&pageIndex=${page.prePage}">Previous page</a>
            <#else>
                <span>Previous page</span>
            </#if>
            <#assign
                start=1
                end=page.totalPage
            />
            <#if (page.pageIndex-5) gt start>
                <#assign start=page.pageIndex-4/>
            </#if>
            <#if (page.pageIndex+5) lt end>
                <#assign end=page.pageIndex+4/>
            </#if>
            <#if start gt 1>
                <a href="?word=${word!}&tagId=${tagId!}">1</a> ...
            </#if>
            <#list start..end as n>
                <#if n=page.pageIndex>
                    ${n}
                <#else>
                    <a href="?word=${word!}&tagId=${tagId!}&pageIndex=${n}">${n}</a>
                </#if>
            </#list>
            <#if end lt page.totalPage>
                ... <a href="?word=${word!}&tagId=${tagId!}&pageIndex=${page.totalPage}">${page.totalPage}</a>
            </#if>
            <#if !page.lastPage>
                <a href="?word=${word!}&tagId=${tagId!}&pageIndex=${page.nextPage}">Next page</a>
            <#else>
                <span>Next page</span>
            </#if>
        </div>
    </#if>
</@_search>
        <aside>
            <h3>Popular content</h3>
            <ul>
<@_contentList orderField='clicks' pageSize=10>
    <#list page.list as a>
                <li><a href="<#if a.onlyUrl>${site.dynamicPath}content/redirect?id=${a.id}<#else>${a.url!}</#if>" target="_blank">${a.title}</a><span>${a.clicks}</span></li>
    </#list>
</@_contentList>
            </ul>
        </aside>
    </main>
    <footer>
        Copyright &copy; ${.now?string('yyyy')}
    </footer>
    <script src="${site.dynamicPath}resource/js/cms.analytics.js"></script>
    <script>
        var ca = cmsAnalytics();
        var url='${site.dynamicPath}api/visit/record';
        if("string" ==typeof itemString){
            url=url+"?"+itemString;
        }
        ca.report(url);
    </script>
</body>
</html>