diff --git a/src/Pages/Posts/Category_/Post_.elm b/src/Pages/Posts/Category_/Post_.elm index d275a25..ebf4ef6 100644 --- a/src/Pages/Posts/Category_/Post_.elm +++ b/src/Pages/Posts/Category_/Post_.elm @@ -133,7 +133,7 @@ view model = , alt blog.meta.title ] [] - , articleNode blog.content model.fragment + , articleNode blog.content model.fragment blog.meta.title blog.meta.description , Html.div [ class "text-center text-neutral-300 border-t border-dashed border-teal-500 p-2" ] [ Html.time [ datetime blog.meta.date ] [ Html.text <| "Published on " ++ UU.getFormattedDate blog.meta.date ++ " under " ] , Html.a [ href "https://www.mozilla.org/en-US/MPL/2.0/" ] [ Html.text "Mozilla Public License 2.0" ] @@ -243,10 +243,14 @@ errorView error = ] -articleNode : String -> String -> Html Msg -articleNode data fragment = +articleNode : String -> String -> String -> String -> Html Msg +articleNode data fragment title description = Html.node "rendered-md" - [ Html.Attributes.attribute "markdowndata" data, Html.Attributes.attribute "fragment" fragment ] + [ Html.Attributes.attribute "markdowndata" data + , Html.Attributes.attribute "fragment" fragment + , Html.Attributes.attribute "title" title + , Html.Attributes.attribute "description" description + ] [] @@ -257,7 +261,7 @@ articleNode data fragment = type alias YamlMeta = { title : String , date : String - , description : Maybe String + , description : String , tags : List String , category : String , image : String @@ -293,7 +297,7 @@ metaDecoder = Yaml.map7 YamlMeta (Yaml.field "title" Yaml.string) (Yaml.field "date" Yaml.string) - (Yaml.maybe (Yaml.field "description" Yaml.string)) + (Yaml.field "description" Yaml.string) (Yaml.field "tags" (Yaml.list Yaml.string)) (Yaml.field "category" Yaml.string) (Yaml.field "image" Yaml.string) diff --git a/src/web-components/MarkedRender.js b/src/web-components/MarkedRender.js index 79e06b9..cde812e 100644 --- a/src/web-components/MarkedRender.js +++ b/src/web-components/MarkedRender.js @@ -8,10 +8,26 @@ customElements.define( connectedCallback() { this.runMarked(); } + + updateMeta(title, description) { + document.querySelector('meta[name="title"]').setAttribute("content", title + " | Avinal Kumar | Personal Website"); + document.querySelector('meta[name="description"]').setAttribute("content", description); + document.querySelector('meta[property="og:title"]').setAttribute("content", title + " | Avinal Kumar | Personal Website"); + document.querySelector('meta[property="og:description"]').setAttribute("content", description); + document.querySelector('meta[property="og:url"]').setAttribute("content", window.location); + document.querySelector('meta[property="twitter:title"]').setAttribute("content", title + " | Avinal Kumar | Personal Website"); + document.querySelector('meta[property="twitter:description"]').setAttribute("content", description); + document.querySelector('meta[property="twitter:url"]').setAttribute("content", window.location); + } + runMarked() { const renderer = new marked.Renderer(); const data = this.getAttribute("markdowndata"); const fragment = this.getAttribute("fragment"); + const title = this.getAttribute("title"); + const description = this.getAttribute("description"); + this.updateMeta(title, description); + var lead = 0; renderer.heading = (text, level) => { if (level === 1) { @@ -74,13 +90,13 @@ customElements.define( this.innerHTML = marked.parse(data); console.log("Markdown rendering complete!"); if (fragment) { - console.log("Fragment found, scrolling to: #", fragment); + console.log(`Fragment found, scrolling to: ${window.location}#${fragment}`); window.location = "#" + fragment; } } static get observedAttributes() { - return ["markdowndata", "fragment"]; + return ["markdowndata", "fragment", "title", "description"]; } } ); diff --git a/static/sitemap.xml b/static/sitemap.xml index e6d9d77..b5a1bd3 100644 --- a/static/sitemap.xml +++ b/static/sitemap.xml @@ -99,13 +99,40 @@ https://avinal.space/posts/gsoc/meeting-9 2023-01-30T22:02:32+05:30 + + https://avinal.space/posts/blogs/hey-tekton-results + 2023-03-28T14:13:21+05:30 + https://avinal.space/meet + 2023-03-28T14:13:21+05:30 + + + https://avinal.space/posts + 2023-03-28T14:13:21+05:30 + + + https://avinal.space/posts/blogs + 2023-03-28T14:13:21+05:30 + + + https://avinal.space/posts/development + 2023-03-28T14:13:21+05:30 + + + https://avinal.space/posts/gsoc + 2023-03-28T14:13:21+05:30 + + + https://avinal.space/posts/articles + 2023-03-28T14:13:21+05:30 https://avinal.space/pages/about-me + 2023-03-28T14:13:21+05:30 https://avinal.space/pages/projects + 2023-03-28T14:13:21+05:30 \ No newline at end of file