mirror of
https://github.com/avinal/avinal.github.io.git
synced 2026-07-04 07:40:09 +05:30
dynamically updating mets tags
Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
This commit is contained in:
@@ -133,7 +133,7 @@ view model =
|
|||||||
, alt blog.meta.title
|
, 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.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.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" ]
|
, 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 : String -> String -> String -> String -> Html Msg
|
||||||
articleNode data fragment =
|
articleNode data fragment title description =
|
||||||
Html.node "rendered-md"
|
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 =
|
type alias YamlMeta =
|
||||||
{ title : String
|
{ title : String
|
||||||
, date : String
|
, date : String
|
||||||
, description : Maybe String
|
, description : String
|
||||||
, tags : List String
|
, tags : List String
|
||||||
, category : String
|
, category : String
|
||||||
, image : String
|
, image : String
|
||||||
@@ -293,7 +297,7 @@ metaDecoder =
|
|||||||
Yaml.map7 YamlMeta
|
Yaml.map7 YamlMeta
|
||||||
(Yaml.field "title" Yaml.string)
|
(Yaml.field "title" Yaml.string)
|
||||||
(Yaml.field "date" 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 "tags" (Yaml.list Yaml.string))
|
||||||
(Yaml.field "category" Yaml.string)
|
(Yaml.field "category" Yaml.string)
|
||||||
(Yaml.field "image" Yaml.string)
|
(Yaml.field "image" Yaml.string)
|
||||||
|
|||||||
@@ -8,10 +8,26 @@ customElements.define(
|
|||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
this.runMarked();
|
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() {
|
runMarked() {
|
||||||
const renderer = new marked.Renderer();
|
const renderer = new marked.Renderer();
|
||||||
const data = this.getAttribute("markdowndata");
|
const data = this.getAttribute("markdowndata");
|
||||||
const fragment = this.getAttribute("fragment");
|
const fragment = this.getAttribute("fragment");
|
||||||
|
const title = this.getAttribute("title");
|
||||||
|
const description = this.getAttribute("description");
|
||||||
|
this.updateMeta(title, description);
|
||||||
|
|
||||||
var lead = 0;
|
var lead = 0;
|
||||||
renderer.heading = (text, level) => {
|
renderer.heading = (text, level) => {
|
||||||
if (level === 1) {
|
if (level === 1) {
|
||||||
@@ -74,13 +90,13 @@ customElements.define(
|
|||||||
this.innerHTML = marked.parse(data);
|
this.innerHTML = marked.parse(data);
|
||||||
console.log("Markdown rendering complete!");
|
console.log("Markdown rendering complete!");
|
||||||
if (fragment) {
|
if (fragment) {
|
||||||
console.log("Fragment found, scrolling to: #", fragment);
|
console.log(`Fragment found, scrolling to: ${window.location}#${fragment}`);
|
||||||
window.location = "#" + fragment;
|
window.location = "#" + fragment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static get observedAttributes() {
|
static get observedAttributes() {
|
||||||
return ["markdowndata", "fragment"];
|
return ["markdowndata", "fragment", "title", "description"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -99,13 +99,40 @@
|
|||||||
<loc>https://avinal.space/posts/gsoc/meeting-9</loc>
|
<loc>https://avinal.space/posts/gsoc/meeting-9</loc>
|
||||||
<lastmod>2023-01-30T22:02:32+05:30</lastmod>
|
<lastmod>2023-01-30T22:02:32+05:30</lastmod>
|
||||||
</url>
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>https://avinal.space/posts/blogs/hey-tekton-results</loc>
|
||||||
|
<lastmod>2023-03-28T14:13:21+05:30</lastmod>
|
||||||
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://avinal.space/meet</loc>
|
<loc>https://avinal.space/meet</loc>
|
||||||
|
<lastmod>2023-03-28T14:13:21+05:30</lastmod>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>https://avinal.space/posts</loc>
|
||||||
|
<lastmod>2023-03-28T14:13:21+05:30</lastmod>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>https://avinal.space/posts/blogs</loc>
|
||||||
|
<lastmod>2023-03-28T14:13:21+05:30</lastmod>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>https://avinal.space/posts/development</loc>
|
||||||
|
<lastmod>2023-03-28T14:13:21+05:30</lastmod>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>https://avinal.space/posts/gsoc</loc>
|
||||||
|
<lastmod>2023-03-28T14:13:21+05:30</lastmod>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>https://avinal.space/posts/articles</loc>
|
||||||
|
<lastmod>2023-03-28T14:13:21+05:30</lastmod>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://avinal.space/pages/about-me</loc>
|
<loc>https://avinal.space/pages/about-me</loc>
|
||||||
|
<lastmod>2023-03-28T14:13:21+05:30</lastmod>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://avinal.space/pages/projects</loc>
|
<loc>https://avinal.space/pages/projects</loc>
|
||||||
|
<lastmod>2023-03-28T14:13:21+05:30</lastmod>
|
||||||
</url>
|
</url>
|
||||||
</urlset>
|
</urlset>
|
||||||
Reference in New Issue
Block a user