public static string GetPageInfoHeadScript(PageInfo pageInfo, ContextInfo contextInfo) { var builder = new StringBuilder(); builder.Append( $@"<script>var $pageInfo = {{publishmentSystemID : {pageInfo.PublishmentSystemId}, channelID : {pageInfo.PageNodeId}, contentID : {pageInfo.PageContentId}, siteUrl : ""{pageInfo.PublishmentSystemInfo.PublishmentSystemUrl.TrimEnd('/')}"", homeUrl : ""{pageInfo.HomeUrl.TrimEnd('/')}"", currentUrl : ""{StlUtility.GetStlCurrentUrl(pageInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo)}"", rootUrl : ""{PageUtils.GetRootUrl(string.Empty).TrimEnd('/')}"", apiUrl : ""{pageInfo.ApiUrl.TrimEnd('/')}""}};</script>"); foreach (string key in pageInfo.PageHeadScriptKeys) { var js = pageInfo.GetPageHeadScripts(key); if (!string.IsNullOrEmpty(js)) { builder.Append(js); } } return(builder.ToString()); }
public static string GetPageInfoHeadScript(PageInfo pageInfo, ContextInfo contextInfo) { var builder = new StringBuilder(); builder.Append( $@"<script>var $pageInfo = {{siteId : {pageInfo.SiteId}, channelId : {pageInfo.PageChannelId}, contentId : {pageInfo.PageContentId}, siteUrl : ""{pageInfo.SiteInfo.Additional.WebUrl.TrimEnd('/')}"", currentUrl : ""{StlUtility.GetStlCurrentUrl(pageInfo.SiteInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo, pageInfo.TemplateInfo.TemplateType, pageInfo.TemplateInfo.Id, pageInfo.IsLocal)}"", rootUrl : ""{PageUtils.GetRootUrl(string.Empty).TrimEnd('/')}"", apiUrl : ""{pageInfo.ApiUrl.TrimEnd('/')}""}};</script>"); foreach (string key in pageInfo.PageHeadScriptKeys) { var js = pageInfo.GetPageHeadScripts(key); if (!string.IsNullOrEmpty(js)) { builder.Append(js); } } return(builder.ToString()); }