Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Footer “edit me” link #56

Closed
mbostock opened this issue Oct 23, 2023 · 5 comments · Fixed by #1255
Closed

Footer “edit me” link #56

mbostock opened this issue Oct 23, 2023 · 5 comments · Fixed by #1255
Labels
design Designs needed for a polished UI enhancement New feature or request

Comments

@mbostock
Copy link
Member

If a project is hosted on GitHub (or other hosting service), it’d be nice if we could automatically generate an “edit me” link in the footer.

@mbostock mbostock added the enhancement New feature or request label Oct 23, 2023
@Fil
Copy link
Contributor

Fil commented Oct 26, 2023

I was imagining the page generator (parseMarkdown?) would have access to the path (and pass it probably in the context), so we could (or a theme could) add a “view source” component — which might point to a github repo or something else. Maybe in the page footer (#55).

@cinxmo cinxmo added the design Designs needed for a polished UI label Oct 31, 2023
@mbostock mbostock modified the milestones: General availability, Future Nov 13, 2023
@Fil
Copy link
Contributor

Fil commented Feb 13, 2024

related #739

@Fil
Copy link
Contributor

Fil commented Mar 12, 2024

Here's my take on this, in observablehq.config.js:

const SOURCE_REPO = "https://github.com/USER/PROJECT/blob/main/docs";

const VIEW_SOURCE = `
<style>
a.view-source {
  position: absolute;
  top: 0;
  right: 0;
  font: 700 18px var(--sans-serif);
  text-decoration: none !important;
  padding: 0 4px;
}
a.view-source:not(:hover,:focus) {
  color: inherit;
}
</style>
<a class="view-source" target="_blank" aria-label="view source" title="view source" href="${SOURCE_REPO}">⚉</a>
<script type="module">
const a = document.querySelector(".view-source");
a.setAttribute("href", a.getAttribute("href") + (document.location.pathname.replace(/[/]$/, "/index")) + ".md?plain=1"
);
</script>
`;


export default {
  header: ${VIEW_SOURCE}
};

@jaanli
Copy link

jaanli commented Mar 13, 2024

Would be nice to support non-GitHub hosted (but still open source) websites!

@Fil
Copy link
Contributor

Fil commented Mar 23, 2024

I think we have enough possibilities now for a user to add their own links in header or footer. It could be nice to support passing these options as functions that would receive a bit of context (page name, page url)?

@mbostock mbostock removed this from the Future milestone Mar 24, 2024
Fil added a commit that referenced this issue Apr 17, 2024
that receives the page’s meta data (path, title and unrestricted front matter), and returns an HTML fragment (string).

closes #56
partially addresses #1036
@Fil Fil closed this as completed in #1255 May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Designs needed for a polished UI enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants